原文:Hiberate 更新时报错 a different object with the same identifier value was already associated with the session

使用的是Hibernate框架,Service类里有这样一个方法: 实际执行的时候会在第 行 根据前面的条件跳转到这里 报错:a different object with the same identifier value was already associated with the session。 解决方法:后来改成merge 方法就可以了。 原因:从上下文来看,这里在保存前先去数据库中取 ...

2014-12-23 19:28 1 9255 推荐指数:

查看详情

a different object with the same identifier value was already associated with the session

这个问题,我把对象赋值为NULL,也是很好用的.在我的系统中,更新好用了,可是插入不好用了.没改前,是插入好用,而更新不好用.本来是系统中的问题,可是,catch只是捕捉到,从但是,没有把log打印出来,找原因实在是难找.在高度数据库时,最好把异常捕捉中的信息打印 ...

Thu May 10 13:21:00 CST 2012 0 13327
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM