To make an entity persist, we need to create an EntityManager object for it. We can easily do that by first creating an EntityManagerFactory and constructing an EntityManager through it.
For example, the following code creates an EntityManagerFactory for the Employee entity through the interface provided in the java.persistance package.
Next, we will get an EntityManager from this factory and initialize a transaction through it.
After this, we persist whatever data we wish, into the database. In our case, it is an Employee object e_obj.
Finally, we end the transaction and free the factory.