Thanks for your comment, after that I've come to read about it in the Java
Persistence Wikibook I've found the cause of the problem.

https://en.wikibooks.org/wiki/Java_Persistence/OneToMany#Getters_and_Setters

Last two paragraphs:

/
Some expect the JPA provider to have magic that automatically maintains
relationships. This was actually part of the EJB CMP 2 specification.
However the issue is if the objects are detached or serialized to another
VM, or new objects are related before being managed, or the object model is
used outside the scope of JPA, then the magic is gone, and the application
is left figuring things out, so in general it may be better to add the code
to the object model. However some JPA providers do have support for
automatically maintaining relationships.

In some cases it is undesirable to instantiate a large collection when
adding a child object. One solution is to not map the bi-directional
relationship, and instead query for it as required. Also some JPA providers
optimize their lazy collection objects to handle this case, so you can still
add to the collection without instantiating it.
/

It seems to me that in the original application (EJB CMP2) the relationships
were bi-directional, and because of that this "magic" of maintaining the two
sides of the relationship was done automatically.

So now that I use OpenEJB with JPA I have to do this "magic" manually and
delete all bi-directional relationships which are likelly to get really big.

Thanks for your comments.

Tomás



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/Problem-with-Tomee-on-ejbPostCreate-method-OutOfMemoryError-tp4676642p4676652.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Reply via email to