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

Reply via email to