importcom.domain.Customer;importcom.utils.JPAUtils;importorg.junit.Test;importjavax.persistence.EntityManager;importjavax.persistence.EntityTransaction;importjavax.persistence.Query;importjava.util.List;public classJPATest01 {//保存操作 persist()
@Testpublic voidTest01(){
Customer c=newCustomer();
c.setName("曹操");
c.setLovel("实诚");//1.获取EntityManager
EntityManager em=JPAUtils.createEntityManager();//2.获取事务开启事务
EntityTransaction tx =em.getTransaction();
tx.begin();//3.执行保存操作,persist()方法
em.persist(c);//释放资源
tx.commit();
em.close();
}//查询单个实体操作 find()立即加载
@Testpublic voidTest02_1(){//1.获取EntityManager
EntityManager em=JPAUtils.createEntityManager();//2.获取事务开启事务
EntityTransaction tx =em.getTransaction();
tx.begin();//3.查询出对象
Customer customer = em.find(Cu