Announcement Announcement Module
No announcement yet.
Shared EntityManager help Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shared EntityManager help

    currently, im creating an entityManagerFactory like normal, and am injecting that factory to my dao's, so everytime i execute a query, the dao creates an entitymanager, is it possible to have a shared EntityManager as specified in the api of JpaTemplate

  • #2
    im not an expert in JPA, but be aware of using shared entity manager. As i know, EntityManager acts as a "wrapper" of Session of Hibernate (if you use hibernate), that means that it is the first level cache. If session is shared, this cache will grow every time you make queries, so be careful of flushing you this session, so no performance problems could be appeared. Of course this is controlled by Spring, see at chapter 12.6.3 , and you will see @PersitanceContext example and how it is used for injecting entity manager instead of the factory.