Depending on how the Entitymanager object is managed, there are two types of these:
-Container-managed (container-managed) Entitymanager objects
Container-managed Entitymanager objects are the simplest, and programmers do not need to consider the release of Entitymanager connections, as well as complex issues such as transactions, all of which are given to the container to manage. Container-managed Entitymanager objects must run in the EJB container, not in the Web container and the J2SE environment. If Entitymanager objects are obtained by injecting @PersistenceContext annotations, this way of getting Entitymanager objects is managed by the container.
-Apply Managed (application-managed) Entitymanager objects
By applying managed Entitymanager objects, programmers need to manually control their release and connection, manually control transactions, and so on. However, this approach to the application of managed Entitymanager objects can be applied not only in the EJB container, but also from the EJB container and into any Java environment, such as the Web container, the J2SE environment, and so on. So in some ways, this is the basis for JPA to run independently of the EJB environment.
Entitymanager Object Management