It's not a secret anymore!
The moose likes Object Relational Mapping and the fly likes EntityManager managed by application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "EntityManager managed by application" Watch "EntityManager managed by application" New topic

EntityManager managed by application

Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Hello everybody.

I'd like to build a simple solution with JSF and JPA (Hibernate impl). As I'm using tomcat, I think I need to use an entity manager managed by application instead of managed by container.
So I've created an util class that gives EntityManager instances for me as follows in the code below.
I'd like to know if this practice can be used or may cause problems in future because I don't have a way to close my EntityManagerFactory.

Thanks in advance.

Adolfo Eloy
Software Developer
It is sorta covered in the JavaRanch Style Guide.
subject: EntityManager managed by application
jQuery in Action, 3rd edition