EntityManagerFactory creates EntityManager. EntityManagerFactory itself is obtained by calling a static Persistence.createEntityManagerFactory method. An argument to this function is a persistence-unit name that you have specified in persistence.xml.