Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Proper EntityManger in multi-thread App(Is there a proper procedure for using entity managers in a multi-thread application.)
Proper EntityManger in multi-thread App [message #905141] Wed, 29 August 2012 15:38 Go to next message
Chad Curtis is currently offline Chad Curtis
Messages: 8
Registered: July 2012
Location: Minnesota
Junior Member
Is it better to have an entity manager per thread, when shared cache is off, or only open and close an entity manager when you write to the database? This comes from the ConcurrancyManager.acquire() method hanging, for what i can tell is no valid reason. Would separate entity managers per thread solve this?
Re: Proper EntityManger in multi-thread App [message #905333 is a reply to message #905141] Thu, 30 August 2012 03:31 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 806
Registered: July 2009
Senior Member
On 2012-08-29 21:38, Chad Curtis wrote:
> Is it better to have an entity manager per thread, when shared cache is off, or only open and close an entity manager when you write to the database? This comes from the ConcurrancyManager.acquire() method hanging, for what i can tell is no valid reason. Would separate entity managers per thread solve this?

AFAIK an EM is not thread save, so if multiple threads are accessing the same EM, you should either synchronize them, or use separate EM's for each thread.
Re: Proper EntityManger in multi-thread App [message #908652 is a reply to message #905333] Wed, 05 September 2012 14:33 Go to previous message
Chad Curtis is currently offline Chad Curtis
Messages: 8
Registered: July 2012
Location: Minnesota
Junior Member
Thanks for the advice, I went with multiple entity mangers.
Previous Topic:jboss tools hibernate is getting error while installing @ eclipse indigo sr2
Next Topic:Eclipselink 2.3.2 + composite persistence units + bean validation (jsr303)
Goto Forum:
  


Current Time: Thu Apr 24 01:48:38 EDT 2014

Powered by FUDForum. Page generated in 0.01685 seconds