日期:2014-05-17  浏览次数:20640 次

求救!Hibernate事务与saveOfUpdate冲突
a different object with the same identifier value was already associated with the session: [com.sie.gqgx.model.CompanyChangeLogMid#1640016]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.sie.gqgx.model.CompanyChangeLogMid#1640016]


利用spring 配置业务层的事务时,同个方法中多次调用了saveOfUpdate方法时就会报错。
利用了merge()的方法之后在方法调用完后又会报事务回滚的错!

------解决方案--------------------
为了解决session关闭的问题,spring提供了opsessionviewfilter。去web。xml添加以下这个过滤器