Announcement Announcement Module
Collapse
No announcement yet.
Extended EntityManager / JpaTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment

      Working...
      X