users@glassfish.java.net

Re: JPA - entityManager.flush()

From: <glassfish_at_javadesktop.org>
Date: Thu, 17 May 2007 14:55:28 PDT

jsl123,

Sorry, but your solution won't work - a) if you call a method directly, the container is not involved, and it won't start a transaction, but b) if you call your getNextTaskID() via a ref and it indeed starts a new transaction, such transaction will be committed when your method ends, and all locks will be released.

trouby,

It [b]is[/b] a complicated problem. If you mark a row as inProcess and commit the change, but the scanner()'s tx fails, you'll never be able to fix that task - all other queries/threads will think that it is still inProcess and is being taken care of. Which means that you either need another way of modeling his flow or have another method that is marked as timeout which in turn calls the scanner() in a try-catch block, then restore the inProcess value on rollback.

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

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