I am moving a JPA-Hibernate application from a Java EE 6 environment to a Tomcat 7 one.
The application has several DAO classes making queries on the EntityManager. In the Java EE environment I could just inject it using the @PersistenceContext annotation, and let the container manage the EntityManager. Now that I have to do it manually, I was wondering what is the way to go.
Should the entity manager be unique? If so can it be a static final field, created on startup and that every DAO class uses? Does it have a lifecycle that involves closing it and then re-opening it?
@PersistenceContext.