• 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.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!