事务今天弄了一下午,数据能正常提交但是,提交完了之后就是报错,后来终于找到原因希望对大家有所帮助
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 注释掉就好了,因为大多数的事务的配置在数据库中都配置好了,包括哪些方法名开头的事务。
分享到:
相关推荐
TransAtlantic_BioData 该存储库包含通过 TCP 套接字将 OpenBCI 生物信号从处理 GUI 通过 Internet 发送到另一台计算机的所有代码。 它将首先由同时举行的 BCI 蒙特利尔和黑客马拉松的黑客进行测试。 档案文件 ...
14. If the two ISPs do not peer with each other, then when they send traffic to each other they have to send the traffic through a provider ISP (intermediary), to which they have to pay for carrying ...
2.1.4 After the First Transatlantic Transmission 35 2.1.5 Directivity 40 2.2 Antenna Developments During the First World War 44 2.3 Antenna Developments in Between the Wars 47 2.3.1 Broadcasting 47 ...
The growth of transatlantic technol- ogy alliances has continued over recent months. This further illus- trates the increasing strength of the biotechnology sector in Europe, with a majority of ...
The growth of transatlantic technol- ogy alliances has continued over recent months. This further illus- trates the increasing strength of the biotechnology sector in Europe, with a majority of ...
关于隐私和网络安全的跨大西洋对话的第一次会议于 2017 年 11 月在柏林 HIIG 举行,汇集了来自大西洋两岸学术界、行政部门、企业界和民间社会的杰出跨学科专家组。 希望对所涉问题和通用方法有更深入的了解,从而使...