users@glassfish.java.net

Re: Cannot modify entity and collection within entity in same transaction

From: <glassfish_at_javadesktop.org>
Date: Fri, 09 Nov 2007 14:31:43 PST

Check server.log for the reasons of the rollback. It's probably there.

Other things to remember:
- if you use UserTransaction, either lookup EM after you called tx.begin() or call em.joinTransaction() at that point: the EM has no knowledge that you started the transaction and it needs to subscribe to the TxManager commit callbacks.
- you can't call em.getTransaction() for a JTA EM (see spec for this restriction).
- You can inject an EMF into a multi-treaded component and then create EM for the duration of the method call. Such em will be thread-safe, but you must close it in the finally block to avoid memory and resource leaks.

HTH,
-marina
[Message sent by forum member 'mvatkina' (mvatkina)]

http://forums.java.net/jive/thread.jspa?messageID=244839