users@glassfish.java.net

Re: Problem with Toplink Cache & parallel access of 2 servlets

From: <glassfish_at_javadesktop.org>
Date: Fri, 12 Feb 2010 07:04:53 PST

Thanks again for your reply,

so my problem could be that the EntityManager isn't closed at the end of a method. As far as I remember each method I call from a servlet should have its own transaction, managed by the container. I will check that next monday.

But to make sure I got you right: if the EntityManger is closed at the end of each method (resp. he detaches all entities), I can savely work with two servlets on the same data without Optimistic Locking Exceptions being thrown? I'm not referring to the rare case that both servlets invoke the same method at the same time so that they overlap, but to Optimistic Locking Exceptions being thrown by the second servlet minutes after I've last used the first one (so well after the transaction must be over).
[Message sent by forum member 'encey' (martin.enzelsberger_at_gmail.com)]

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