Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How bad is close EM always ?

 
Robert Siqueira
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the following entitymanager producer:



Is there any impact about always close the entitymanger after closed a transaction !??!!? Is there any performance issues ?

Regards,

Robert
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use dependency injection to get it using the @PersistenceContext annotation then you should not close it as this is handled for you. However if you are creating it from the factory as you are in your snippet then absolutely it is your responsibility to make sure it gets closed every time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic