Nov 19th, 2007, 06:38 AM
Extended EntityManager / JpaTemplate
I am using an Application Managed Entity Manager. I move to JpaTemplate because I want to use Spring.
I configure my bean to have a JpaTemplate injected. However, I noticed this is not have an extended persistence context. Application Manager EntityManagers have extended Persistence Contexts by default in JPA but not in Spring?
How do I configure Spring so that the jpaTemplate has an extended Persistence Context?
Nov 19th, 2007, 08:07 AM
I don't this is possible. The JpaTemplate using it's own EntityManager which has a transaction scope not extended scrop.
Originally Posted by beginner2
However it is possible to use Spring to inject an EntityManager Factory to your bean. Once you have a handle to that you can
EntityManager em = entityManagerFactory.createEntityManager();
This em will have extended persistence context.
Mar 10th, 2011, 09:51 AM
Extended JPA with JpaTemplate
The EntityManager used by JpaTemplate is transactional, isn't it? That is: two different objectes (e.g., Dao objects) that invoke JPA operations through a JpaTemplate within the same transaction will use the same EntityManager. However, when the transaction gets finished, any other invocation of a JpaTemplate operation by any object will get a different EntityManager.
If so, is there any natural way to get extended EntityManagers with JpaTemplate?
Thank you very much.