users@glassfish.java.net

Re: JPA - entityManager.flush()

From: <glassfish_at_javadesktop.org>
Date: Fri, 18 May 2007 13:11:22 PDT

In your example above getNextTaskID() is marked with TransactionAttributeType.REQUIRES_NEW which means that even if the lock is placed (it should), it will be released when transaction ends (because the connection will be released at this point), i.e. at the end of this business method (and only if you call it through a ref). Also, the EM (and the persistence context) in the calling method will be different than the one that runs in a new transaction.

Did you try to mark getTask() with TransactionAttributeType.REQUIRES_NEW instead?
[Message sent by forum member 'mvatkina' (mvatkina)]

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