当我试图将关键字段更新到数据库时,这个问题也出现在 session.flush() 和 session.clear() 方法中。
Bean.java
SessionFactory sf = HibernateUtil.getSessionFactory();
Session s = sf.openSession();
Criteria crit3=s.createCriteria(RoleTable.class);
roledata=crit3.list();
for(RoleTable rt:roledata){
Transaction tx = s.beginTransaction();
RoleTable rot=new RoleTable();
rot.setSno(1);
rot.setObtype(rt.getObtype());
rot.setObid(rt.getObid());
rot.setText(rt.getText());
rot.setSdat(rt.getSdat());
rot.setEdat(rt.getEdat());
rot.setUpdate(rt.isUpdate());
rot.setCreate(rt.isCreate());
rot.setDelete(rt.isDelete());
rot.setRead(rt.isRead());
s.update(rot);
s.flush();
s.clear();
tx.commit();
}
s.close();
sf.close();
}