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 19:38 Go to next message
Chad Curtis is currently offline Chad CurtisFriend
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 07:31 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
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 18:33 Go to previous message
Chad Curtis is currently offline Chad CurtisFriend
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: Mon Dec 22 14:24:19 GMT 2014

Powered by FUDForum. Page generated in 0.26151 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software