Student s = new Student("stu1");
SessionFactory sf = HibernateUtils.getSessionFactory();
Session session = sf.openSession();
session.beginTransaction();
session.save(s);
session.evict(s);
session.getTransaction().commit();
session.close();
sf.close();evict看文档的意思是在session缓存里把persistent状态对象移除,之后事务commit()中flush()会同步session缓存中所有对象,但为什么以上代码还会产生insert语句,并持久化到数据库中?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货