Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Re: How can I check PersistenceContexts for equality
Re: How can I check PersistenceContexts for equality [message #758029] Mon, 21 November 2011 18:36 Go to next message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
You EntityManager can either be JTA managed, or RESOURCE_LOCAL unmanaged.

If it is unmanaged, then every time you call createEntityManager, you will get a new EntityManager.

If it is JTA managed, then the EJB container is responsible for creating the EntityManager instance.
The way EJB servers do this is they wrap the real EclipseLink EntityManager in there own proxy. Every transaction will get a different EclipseLink EntityManager, and entity managers should reference the same EclipseLink EntityManager in the same transaction.

In WebLogic and Glassfish I believe a new EclipseLink EntityManager is created each transaction, and thrown away at the end.

In WebSphere I believe it does some caching of the EntityManager in some sort of pool and just calls clear() on them and then puts them back into the pool.

I do not recommend pooling EntityManagers.


--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: How can I check PersistenceContexts for equality [message #758382 is a reply to message #758029] Tue, 22 November 2011 23:17 Go to previous message
Piotr Nowicki is currently offline Piotr Nowicki
Messages: 16
Registered: November 2011
Location: Poland
Junior Member
Thanks a lot James!

You've provided me with a lot of interesting information :)

I would just like to ask - when you've said that:

James wrote on Mon, 21 November 2011 13:36
> In WebLogic and Glassfish I believe a new EclipseLink EntityManager is created each transaction, and thrown away at the end.
>
> In WebSphere I believe it does some caching of the EntityManager in some sort of pool and just calls clear() on them and then puts them back into the pool.
>
> I do not recommend pooling EntityManagers.


by EntityManager and it's pooling/cache'ing - you referred to the Server's proxy for EntityManager or the JPA-Provider EntityManager itself?

Thanks a lot once again!
Previous Topic:Re: PerformanceMonitor in Standalone or OSGI environment?
Next Topic:persist a collection in order
Goto Forum:
  


Current Time: Thu Oct 23 18:32:23 GMT 2014

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

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