1.update更新数据后,再取出没有变化,调整方法:在DAO的update方法总,session.update(repair);tx.commit();session.flush();
2.findbyId方法中:Repair instance = (Repair) session.get("bean.Repair", id);session.evict(instance); 3.修缮物品类型管理连续删除子类时,出错。解决方法: (1)DAO中加入方法: public void deleteSome(String sql) throws Exception { Session session = HibernateSessionFactory.getSession();
Transaction transaction = session.beginTransaction();
try{
int delnum = session.createQuery(sql).executeUpdate();
//System.out.println(delnum);
session.flush();
transaction.commit();
}catch(Exception e){
e.printStackTrace();
transaction.rollback();
throw e;
}
}
注:参考RepairDAO(2)应用时: GstypeDAO gsdao = new GstypeDAO();
gsdao.deleteSome("delete Gstype as a where a.id="+tid);
|
hibernate技巧集合
最新推荐文章于 2019-04-10 20:30:47 发布