异常:org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.tjsoft.system.model.SysCuiDuBan#1300673826484]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.tjsoft.system.model.SysCuiDuBan#1300673826484]
Service方法内容:for (String s : result) {
if (s != null) {
String[] str = s.split(",");
SysCuiDuBan sysCuiDuBan = new SysCuiDuBan();
sysCuiDuBan.setId(String.valueOf((new Date()).getTime()));
sysCuiDuBan.setBsnum(str[0]); // bsnum
sysCuiDuBan.setStatus(str[1]); // status
sysCuiDuBan.setContent(str[2]); // content
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
sysCuiDuBan.setCreatetime(sdf.parse(str[3],pos)); // createtime
sysCuiDuBan.setPerson(str[4]); // person
sysCuiDuBan.setHandler(""); // handler
sysCuiDuBan.setRe("0");
this.sysSupervisionDao.save(sysCuiDuBan);
}
}
Dao方法内容:this.getHibernateTemplate().save(sysCuiDuBan);
如果Service方法中result数组中数据超过2条就会报异常~~ 应该是事物方面的问题~~ 请各位大虾帮忙解决解决~~
Service方法内容:for (String s : result) {
if (s != null) {
String[] str = s.split(",");
SysCuiDuBan sysCuiDuBan = new SysCuiDuBan();
sysCuiDuBan.setId(String.valueOf((new Date()).getTime()));
sysCuiDuBan.setBsnum(str[0]); // bsnum
sysCuiDuBan.setStatus(str[1]); // status
sysCuiDuBan.setContent(str[2]); // content
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
sysCuiDuBan.setCreatetime(sdf.parse(str[3],pos)); // createtime
sysCuiDuBan.setPerson(str[4]); // person
sysCuiDuBan.setHandler(""); // handler
sysCuiDuBan.setRe("0");
this.sysSupervisionDao.save(sysCuiDuBan);
}
}
Dao方法内容:this.getHibernateTemplate().save(sysCuiDuBan);
如果Service方法中result数组中数据超过2条就会报异常~~ 应该是事物方面的问题~~ 请各位大虾帮忙解决解决~~
http://www.cjsdn.com/post/view?bid=2&id=104169
http://hi.baidu.com/fgfd0/blog/item/fa1fc0bf1810890c19d81fba.htmlhttp://blog.csdn.net/xmq_666/archive/2011/03/05/6225867.aspx