当出现a different object with the same identifier value was already associated with the session时,一般是因为在hibernate中同一个session里面有了两个相同标识但是是不同实体。
我直接将接受需要比较的id的list<ab>换成了list<object[]>,再直接将值遍历拿出
就解决这个问题了
List<Object[]> objects=xxService.getObjList("select id from xx where abname=? and isd=0", ab.getabname());
Integer ins=(Integer)(Object)objects.get(0);
if( ab.getId() .equals(ins)){
try {
xxService.update(ab);
} catch (Exception e) {
e.printStackTrace();
}
}