You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Karan Malhi <ka...@gmail.com> on 2007/02/01 05:30:54 UTC

Re: Automatic CMP to JPA mappings

Dain,

I dont know if this is relevant, but does openejb give the ability to plugin
a custom pk generator?

On 1/31/07, Dain Sundstrom <da...@iq80.com> wrote:
>
> I integrated the OpenEBJ2 conversion code which adds all table,
> column and foreign key declarations to the cmp mappings.  Currently,
> if we see that the cmp used a key generator, we always set the bean
> to use IDENTITY pk generation, but we should be able to map all key
> generator types.
>
> Remember, complex primary keys and unknown primary keys don't work.
>
> -dain
>
> On Jan 31, 2007, at 3:31 PM, Dain Sundstrom wrote:
>
> > I have integrated the code that converts the ejb-jar.xml CMP
> > declarations to a JPA entity mappings file.  In addition, I added
> > support for converting the OpenEJB2 CMP mappings (TranQL) mappings
> > to JPA.  There is a fairly extensive test suite that converts the
> > OpenEJB2 itests, Geronimo Daytrader, and the huge CMR mappings that
> > Gianny wrote for OpenEJB2.  The imput -ejb-jar.xml and -openejb-
> > jar.xml and the output -orm.xml files can be found here:
> >
> > https://svn.apache.org/repos/asf/incubator/openejb/trunk/openejb3/
> > container/openejb-core/src/test/resources/convert/oej2/cmp/
> >
> > In addition, the iTests no longer contain explicit mappings for
> > basic CMP beans, and instead rely on the conversion code to
> > generate the mappings.
> >
> > The integration is fairly simple.  We hook the converter in the
> > ConfigurationFactory, where it reads the JAXB tree for the CMP
> > beans and generates a JPA entity mappings JAXB tree.  We then store
> > that xml in the info tree, so later is can be written in the -
> > cmp.jar file we generate for each application (the jar that
> > contains the generated CMP2 implementation classes).
> >
> > The auto generation only kicks in if the bean does not have an
> > explicit persistence-context-ref declared for cmp.  For example,
> > adding the following to a cmp declaration in an ejb-jar.xml file
> > would DISABLE auto conversion:
> >
> >       <persistence-context-ref>
> >         <persistence-context-ref-name>openejb/cmp</persistence-
> > context-ref-name>
> >         <persistence-unit-name>cmp</persistence-unit-name>
> >       </persistence-context-ref>
> >
> > If we, do not find a persistence-context-ref for "openejb/cmp", we
> > assume the bean does not need an auto generated mapping. I don't
> > really like this convention for turning on and off the auto
> > generation, but it was the simplest thing I could think of.
> >
> > I believe all mappings are supported with the exception of complex
> > primary keys and unknown primary keys, neither of which are
> > currently supported.
> >
> > As always, if you have problems, let me know.
> >
> > -dain
> >
>
>


-- 
Karan Malhi

Re: Automatic CMP to JPA mappings

Posted by Dain Sundstrom <da...@iq80.com>.
We just use JPA for cmp, so if the JPA implementation supports  
plugging in a custom pk generator we do.

After a quick review of the OpenJPA docs it looks like they do  
support custom generators, but the docs are a bit weak. http:// 
incubator.apache.org/openjpa/docs/openjpa-0.9.6-incubating/manual/ 
manual.html#ref_guide_sequence_runtime

If you really want do this, I suggest you ask for specifics on the  
OpenJPA mailing list.

-dain

On Jan 31, 2007, at 8:30 PM, Karan Malhi wrote:

> Dain,
>
> I dont know if this is relevant, but does openejb give the ability  
> to plugin
> a custom pk generator?
>
> On 1/31/07, Dain Sundstrom <da...@iq80.com> wrote:
>>
>> I integrated the OpenEBJ2 conversion code which adds all table,
>> column and foreign key declarations to the cmp mappings.  Currently,
>> if we see that the cmp used a key generator, we always set the bean
>> to use IDENTITY pk generation, but we should be able to map all key
>> generator types.
>>
>> Remember, complex primary keys and unknown primary keys don't work.
>>
>> -dain
>>
>> On Jan 31, 2007, at 3:31 PM, Dain Sundstrom wrote:
>>
>> > I have integrated the code that converts the ejb-jar.xml CMP
>> > declarations to a JPA entity mappings file.  In addition, I added
>> > support for converting the OpenEJB2 CMP mappings (TranQL) mappings
>> > to JPA.  There is a fairly extensive test suite that converts the
>> > OpenEJB2 itests, Geronimo Daytrader, and the huge CMR mappings that
>> > Gianny wrote for OpenEJB2.  The imput -ejb-jar.xml and -openejb-
>> > jar.xml and the output -orm.xml files can be found here:
>> >
>> > https://svn.apache.org/repos/asf/incubator/openejb/trunk/openejb3/
>> > container/openejb-core/src/test/resources/convert/oej2/cmp/
>> >
>> > In addition, the iTests no longer contain explicit mappings for
>> > basic CMP beans, and instead rely on the conversion code to
>> > generate the mappings.
>> >
>> > The integration is fairly simple.  We hook the converter in the
>> > ConfigurationFactory, where it reads the JAXB tree for the CMP
>> > beans and generates a JPA entity mappings JAXB tree.  We then store
>> > that xml in the info tree, so later is can be written in the -
>> > cmp.jar file we generate for each application (the jar that
>> > contains the generated CMP2 implementation classes).
>> >
>> > The auto generation only kicks in if the bean does not have an
>> > explicit persistence-context-ref declared for cmp.  For example,
>> > adding the following to a cmp declaration in an ejb-jar.xml file
>> > would DISABLE auto conversion:
>> >
>> >       <persistence-context-ref>
>> >         <persistence-context-ref-name>openejb/cmp</persistence-
>> > context-ref-name>
>> >         <persistence-unit-name>cmp</persistence-unit-name>
>> >       </persistence-context-ref>
>> >
>> > If we, do not find a persistence-context-ref for "openejb/cmp", we
>> > assume the bean does not need an auto generated mapping. I don't
>> > really like this convention for turning on and off the auto
>> > generation, but it was the simplest thing I could think of.
>> >
>> > I believe all mappings are supported with the exception of complex
>> > primary keys and unknown primary keys, neither of which are
>> > currently supported.
>> >
>> > As always, if you have problems, let me know.
>> >
>> > -dain
>> >
>>
>>
>
>
> -- 
> Karan Malhi