写单元测试 试试
@Test
public void Test(){
EntityManagerFactory factory = Persistence.createEntityManagerFactory("shop");
EntityManager em= factory.createEntityManager();
em.getTransaction().begin();
//操作
em.getTransaction().commit();
em.close();
factory.close();
}