EntityManager is an object with an interface for executing the following operations for the database:
If you register an entity for EntityManager, the entity state is perpetuated in the database at an appropriate time such as when the transaction is committed.
Also, EntityManager has a relation with the persistence context that expresses the entity set. When you register the entity in EntityManager, the entity belongs to a specific persistence context. Also, EntityManager manages the entity lifecycle.
The entity set managed by EntityManager is defined with a unit called the persistence unit. You define the persistence unit in the application configuration file persistence.xml.
The notes on the persistence context and persistence unit are as follows: