EntityManager em = factory.createEntityManager(); // retrieve the customer object from the database Customer customer = em.find(Customer.class, customerId); // make changes to the customer object customer.setFirstName("John"); customer.setLastName("Doe"); // save the changes back to the database em.getTransaction().begin(); em.merge(customer); em.getTransaction().commit();In this example, we first retrieve the Customer object from the database using EntityManager's find() method. We then make changes to the customer object, and save those changes back to the database using merge(). The package library for javax.persistence.EntityManager is javax.persistence, which is included in the Java Persistence API (JPA) library.