You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Aaron Mulder <am...@alumni.princeton.edu> on 2005/07/08 03:28:19 UTC

PK Generator Status

	So I've put in the new PK generator configuration syntax.  Once 
again, the openejb-jar.xml syntax has changed.  The old style of declaring 
a separate PK Generator GBean is still supported, but with a different 
element.  I'm going to update the wiki shortly.

	There are some TranQL enhancements that would be nice:

1) Implement a PK Generator that handles an EJB on a table that 
automatically populates a PK value in itself (via an AUTO_INCREMENT column 
or a trigger or whatever).  I think it would basically just hold a column 
name, and then the part of TranQL that created entities would need logic 
to recognize that, perform the insert as usual, and then fetch the PK ID 
value as an auto-generated key afterward.

2) If the option is implemented to dump DDL on startup, add the DDL for 
each PK Generator too (with, for example, the INSERTs necessary for a 
sequence table generator).  I like that more than having the PK Generator 
try to initialize its own tables or whatever on every startup and just 
suppress any exceptions.

Aaron

Re: PK Generator Status

Posted by Jacek Laskowski <jl...@apache.org>.
Aaron Mulder wrote:

> <key-generator xmlns="http://www.openejb.org/xml/ns/pkgen">
>    ...
> </key-generator>
> 
> 	I'll change the loading code to automatically override the 
> namespace so this isn't a problem in the future.

I saw it on Wiki, but didn't notice the namespace difference! Would you 
take care of loosing the requirement so that it's not required? Thanks.

....after a few moments...

For the record: Aaron has just helped me to get rid of it while chatting 
on IRC!

> Aaron

Jacek


Re: PK Generator Status

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
Jacek,
	It looks like the namespace is wrong.  The key-generator element 
comes from http://www.openejb.org/xml/ns/pkgen and it's complaining that 
yours comes from http://www.openejb.org/xml/ns/openejb-jar.  In the short 
term, try adding an xmlns attribute to the key-generator element:

<key-generator xmlns="http://www.openejb.org/xml/ns/pkgen">
   ...
</key-generator>

	I'll change the loading code to automatically override the 
namespace so this isn't a problem in the future.

Aaron

On Sat, 9 Jul 2005, Jacek Laskowski wrote:
> Aaron,
> 
> I'm out of clues why it doesn't work for me. I've built 
> Geronimo+OpenEJB+TranQL several times and every time I deploy CMPs I'm 
> getting the following exception:
> 
>      [java] org.apache.geronimo.common.DeploymentException: 
> org.apache.xmlbeans.XmlException: Invalid deployment descriptor: 
> [c:\temp\geronimo-deployment-8761tmp
> :0: error: Element not allowed: 
> key-generator@http://www.openejb.org/xml/ns/openejb-jar in element 
> entity@http://www.openejb.org/xml/ns/openejb-jar]
>      [java] Descriptor: <xml-fragment configId="customer-ejb" 
> xmlns:naming="http://geronimo.apache.org/xml/ns/naming" 
> xmlns:open="http://www.openejb.org/xml/ns/o
> penejb-jar">
> 
> I confirmed that the element was indeed allowed according to the schema, 
> but somehow it's not accepted at deployment.
> 
> See my other thread 'PetStore 1.3.2 goes to sandbox' if you want to take 
> a look at its configuration yourself and would like to give me some 
> hints as to why it might be failing and let me go on.
> 
> > Aaron
> 
> Jacek
> 
> 

Re: PK Generator Status

Posted by Jacek Laskowski <jl...@apache.org>.
Aaron Mulder wrote:
> 	So I've put in the new PK generator configuration syntax.  Once 
> again, the openejb-jar.xml syntax has changed.  The old style of declaring 
> a separate PK Generator GBean is still supported, but with a different 
> element.

Aaron,

I'm out of clues why it doesn't work for me. I've built 
Geronimo+OpenEJB+TranQL several times and every time I deploy CMPs I'm 
getting the following exception:

     [java] org.apache.geronimo.common.DeploymentException: 
org.apache.xmlbeans.XmlException: Invalid deployment descriptor: 
[c:\temp\geronimo-deployment-8761tmp
:0: error: Element not allowed: 
key-generator@http://www.openejb.org/xml/ns/openejb-jar in element 
entity@http://www.openejb.org/xml/ns/openejb-jar]
     [java] Descriptor: <xml-fragment configId="customer-ejb" 
xmlns:naming="http://geronimo.apache.org/xml/ns/naming" 
xmlns:open="http://www.openejb.org/xml/ns/o
penejb-jar">

I confirmed that the element was indeed allowed according to the schema, 
but somehow it's not accepted at deployment.

See my other thread 'PetStore 1.3.2 goes to sandbox' if you want to take 
a look at its configuration yourself and would like to give me some 
hints as to why it might be failing and let me go on.

> Aaron

Jacek


Re: PK Generator Status

Posted by Gianny Damour <gi...@optusnet.com.au>.
CMPCreateMethod.execute() implements this logic.

Thanks,
Gianny

On 8/07/2005 10:25 PM, Aaron Mulder wrote:

>Gianny,
>	My understanding of AutoIncrementPrimaryKeyWrapper is that it
>executes an insert on some table during the PK generation phase.  I
>thought that couldn't be the "entity table" since then when the entity
>goes to insert itself it would find that the row already existed.  How is
>it that the AutiIncrement PK generator communicates to the entity that its
>row already exists?
>
>Thanks,
>	Aaron
>
>On Fri, 8 Jul 2005, Gianny Damour wrote:
>  
>
>>>1) Implement a PK Generator that handles an EJB on a table that 
>>>automatically populates a PK value in itself (via an AUTO_INCREMENT column 
>>>or a trigger or whatever).  I think it would basically just hold a column 
>>>name, and then the part of TranQL that created entities would need logic 
>>>to recognize that, perform the insert as usual, and then fetch the PK ID 
>>>value as an auto-generated key afterward.
>>> 
>>>
>>>      
>>>
>>org.tranql.pkgenerator.AutoIncrementTablePrimaryKeyGenerator does that.
>>    
>>
>
>  
>


Re: PK Generator Status

Posted by Gianny Damour <gi...@optusnet.com.au>.
On 8/07/2005 10:37 PM, Aaron Mulder wrote:

>On Fri, 8 Jul 2005, Aaron Mulder wrote:
>  
>
>>Gianny,
>>	My understanding of AutoIncrementPrimaryKeyWrapper is that it
>>executes an insert on some table during the PK generation phase.  I
>>thought that couldn't be the "entity table" since then when the entity
>>goes to insert itself it would find that the row already existed.  How is
>>it that the AutiIncrement PK generator communicates to the entity that its
>>row already exists?
>>    
>>
>
>	Also, what would the SQL be for the AutoIncrementTable primary key 
>wrapper?  Doesn't the CMP engine generate the SQL for an insert into the 
>entity table?  If the AUTO_INCREMENT column is on the entity table then 
>I'd think you'd just want the PK generator to just list the columns that 
>should be populated by the DB so the generated insert statement could skip 
>those and then the CMP engine could fetch the values after the insert was 
>completed.
>  
>
At this stage, the INSERT statement needs to be explicitly provided; 
this can be enhanced.  I confirm that the sql should insert a row in the 
"entity table".

Thanks,
Gianny

>Thanks,
>	Aaron
>
>  
>
>>On Fri, 8 Jul 2005, Gianny Damour wrote:
>>    
>>
>>>>1) Implement a PK Generator that handles an EJB on a table that 
>>>>automatically populates a PK value in itself (via an AUTO_INCREMENT column 
>>>>or a trigger or whatever).  I think it would basically just hold a column 
>>>>name, and then the part of TranQL that created entities would need logic 
>>>>to recognize that, perform the insert as usual, and then fetch the PK ID 
>>>>value as an auto-generated key afterward.
>>>> 
>>>>
>>>>        
>>>>
>>>org.tranql.pkgenerator.AutoIncrementTablePrimaryKeyGenerator does that.
>>>      
>>>
>
>  
>


Re: PK Generator Status

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
On Fri, 8 Jul 2005, Aaron Mulder wrote:
> Gianny,
> 	My understanding of AutoIncrementPrimaryKeyWrapper is that it
> executes an insert on some table during the PK generation phase.  I
> thought that couldn't be the "entity table" since then when the entity
> goes to insert itself it would find that the row already existed.  How is
> it that the AutiIncrement PK generator communicates to the entity that its
> row already exists?

	Also, what would the SQL be for the AutoIncrementTable primary key 
wrapper?  Doesn't the CMP engine generate the SQL for an insert into the 
entity table?  If the AUTO_INCREMENT column is on the entity table then 
I'd think you'd just want the PK generator to just list the columns that 
should be populated by the DB so the generated insert statement could skip 
those and then the CMP engine could fetch the values after the insert was 
completed.

Thanks,
	Aaron

> On Fri, 8 Jul 2005, Gianny Damour wrote:
> > >1) Implement a PK Generator that handles an EJB on a table that 
> > >automatically populates a PK value in itself (via an AUTO_INCREMENT column 
> > >or a trigger or whatever).  I think it would basically just hold a column 
> > >name, and then the part of TranQL that created entities would need logic 
> > >to recognize that, perform the insert as usual, and then fetch the PK ID 
> > >value as an auto-generated key afterward.
> > >  
> > >
> > org.tranql.pkgenerator.AutoIncrementTablePrimaryKeyGenerator does that.
> 

Re: PK Generator Status

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
Gianny,
	My understanding of AutoIncrementPrimaryKeyWrapper is that it
executes an insert on some table during the PK generation phase.  I
thought that couldn't be the "entity table" since then when the entity
goes to insert itself it would find that the row already existed.  How is
it that the AutiIncrement PK generator communicates to the entity that its
row already exists?

Thanks,
	Aaron

On Fri, 8 Jul 2005, Gianny Damour wrote:
> >1) Implement a PK Generator that handles an EJB on a table that 
> >automatically populates a PK value in itself (via an AUTO_INCREMENT column 
> >or a trigger or whatever).  I think it would basically just hold a column 
> >name, and then the part of TranQL that created entities would need logic 
> >to recognize that, perform the insert as usual, and then fetch the PK ID 
> >value as an auto-generated key afterward.
> >  
> >
> org.tranql.pkgenerator.AutoIncrementTablePrimaryKeyGenerator does that.

Re: PK Generator Status

Posted by Gianny Damour <gi...@optusnet.com.au>.
On 8/07/2005 11:28 AM, Aaron Mulder wrote:

>	So I've put in the new PK generator configuration syntax.  Once 
>again, the openejb-jar.xml syntax has changed.  The old style of declaring 
>a separate PK Generator GBean is still supported, but with a different 
>element.  I'm going to update the wiki shortly.
>
>	There are some TranQL enhancements that would be nice:
>
>1) Implement a PK Generator that handles an EJB on a table that 
>automatically populates a PK value in itself (via an AUTO_INCREMENT column 
>or a trigger or whatever).  I think it would basically just hold a column 
>name, and then the part of TranQL that created entities would need logic 
>to recognize that, perform the insert as usual, and then fetch the PK ID 
>value as an auto-generated key afterward.
>  
>
org.tranql.pkgenerator.AutoIncrementTablePrimaryKeyGenerator does that.

Thanks,
Gianny

>2) If the option is implemented to dump DDL on startup, add the DDL for 
>each PK Generator too (with, for example, the INSERTs necessary for a 
>sequence table generator).  I like that more than having the PK Generator 
>try to initialize its own tables or whatever on every startup and just 
>suppress any exceptions.
>
>Aaron
>
>  
>