标签:引用 setname 有一个 hiberna print ati play nsa 提交
public class StudentTest { public static void main(String[] args) { SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction(); Class c1 = new Class(); //临时对象1 c1.setName("08计本"); Class c2 = new Class(); //临时对象2 c2.setName("09计本"); session.save(c1); //持久化对象 session.save(c2); //持久化对象 session.delete(c2); //删除对象 session.getTransaction().commit(); //提交事务 session.close(); //关闭session System.out.println(c1.getName()); //游离对象 System.out.println(c2.getName()); //删除对象 } }
解释:
标签:引用 setname 有一个 hiberna print ati play nsa 提交
原文地址:http://www.cnblogs.com/tenWood/p/7252993.html