This is my work in progress so far: https://github.com/apache/tomee/pull/222
.

I'd like to incorporate some Arquillian tests today, and ensure that this
works with things like relationships between entities.

The change here is fairly straightforward though; we pick up a persistence
unit called "cmp", if one has been defined, and read all the elements on
it. If an entity has been defined in one of those mappings files, we add
the entity class to a set, and the CMP/JPA processing will simply ignore
it. The persistence provider should then use the mapping that has been
defined in the mapping file and not generate its own.

I'll post further updates here, but feedback is welcome.

Jon

On Wed, Nov 28, 2018 at 11:50 AM Jonathan Gallimore <
[email protected]> wrote:

> Hi
>
> This continues on from the work that Otavio did on this thread: "Creates
> an unmarshal that does not filter to JavaEE namespace".
>
> For those of you who aren't aware, TomEE supports CMP entity beans (which
> is quite an old way of doing persistence - it dates back to the EJB 2.1 era
> - and possibly earlier, I started using EJB around 2.1), and it does this
> by converting them to JPA entities on the fly and creating an ORM mapping
> file in XML for the persistence provider to use. It uses a special
> persistence unit called "cmp".
>
> One of the nice things you can do is use
> the openejb.descriptors.output=true system property, and you'll get the
> persistence.xml and orm.xml file that was generated at deploy time.
> Unfortunately, if you try and customize the ORM xml, and provide both the
> persistence xml and ORM xml files in your app, using the <mapping-file> tag
> in persistence.xml (something like the example below), it doesn't work, and
> the auto generated mappings are still used instead.
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"; version="2.0">
>     <persistence-unit name="cmp" transaction-type="JTA">
>         <jta-data-source>jta-ds</jta-data-source>
>         <non-jta-data-source>non-jta-ds</non-jta-data-source>
>         <mapping-file>META-INF/openejb-cmp-generated-orm.xml</mapping-file>
>         <class>...</class>
>         ...
>         <exclude-unlisted-classes>true</exclude-unlisted-classes>
>     </persistence-unit>
> </persistence>
>
> I've reproduced this in a test, and am working on a fix. Doesn't look like
> it'll be too hard. https://issues.apache.org/jira/browse/TOMEE-2295 is
> the JIRA, and I'll post a PR here for review and discussion when I'm done.
>
> Cheers
>
> Jon
>

Reply via email to