hibernate 批处理不能正常提交 ,transatlantic not successfully started
事务今天弄了一下午,数据能正常提交但是,提交完了之后就是报错,后来终于找到原因希望对大家有所帮助
Session session=this.getSessionFactory().getCurrentSession(); Transaction transation = session.beginTransaction(); try { MesXtpzXcxtb obj=new MesXtpzXcxtb(object.getId()+"01","属性", sjbh,0L,1L, "属性", new Date(),xgr ,new Date(),xgr, 0); MesXtpzXcxtb obj1=new MesXtpzXcxtb(object.getId()+"02","监测点", sjbh,0L,2L, "监测点", new Date(),xgr ,new Date(),xgr, 0); MesXtpzXcxtb obj2=new MesXtpzXcxtb(object.getId()+"03","故障类型", sjbh,0L,3L, "故障类型", new Date(),xgr ,new Date(),xgr, 0); MesXtpzXcxtb obj3=new MesXtpzXcxtb(object.getId()+"04","运行信号", sjbh,0L,4L, "运行信号", new Date(),xgr ,new Date(),xgr, 0); session.save(object); session.save(obj); session.save(obj1); session.save(obj2); session.save(obj3); session.flush(); -------------------------------------------//transation.commit(); } catch (Exception e) { // TODO Auto-generated catch block flag=false; e.printStackTrace(); transation.rollback(); } finally { //session.close(); } return flag;
-------------------------------------------//transation.commit();
关键点就在于红色部分,把commit 注释掉就好了,因为大多数的事务的配置在数据库中都配置好了,包括哪些方法名开头的事务。
相关推荐
九天银河技术 2020-11-11
zhangjie 2020-11-11
Crazyshark 2020-11-13
步知道 2020-10-27
tufeiax 2020-09-03
李轮清 2020-09-15
85251846 2020-09-14
wangpaiyonghu 2020-06-28
jackalwb 2020-06-14
yhljxy 2020-06-14
myveer 2020-06-14
xiaobaif 2020-06-14
klarclm 2020-06-13
songshijiazuaa 2020-06-13
TMD咯MySQL 2020-06-12
archive 2020-06-12
清风徐来水波不兴 2020-06-09