Results 1 to 3 of 3

Thread: Extended EntityManager / JpaTemplate

  1. #1
    Join Date
    Nov 2007
    Posts
    5

    Default Extended EntityManager / JpaTemplate

    Hi,
    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?
    Thanks

  2. #2
    Join Date
    Nov 2007
    Posts
    5

    Default

    Quote Originally Posted by beginner2 View Post
    Hi,
    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?
    Thanks
    I don't this is possible. The JpaTemplate using it's own EntityManager which has a transaction scope not extended scrop.

    However it is possible to use Spring to inject an EntityManager Factory to your bean. Once you have a handle to that you can
    do

    EntityManager em = entityManagerFactory.createEntityManager();

    This em will have extended persistence context.

  3. #3
    Join Date
    Jun 2008
    Posts
    6

    Default Extended JPA with JpaTemplate

    Hello,

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •