Hibernate exception: A different object with the same identifier value was already associated with the session
当执行hibernaete 的update方法时出现这个exception的原因:
有2个detached objec 有相同的oid在同一个session中, 可能的原因是之前通过hibernate load方法加载过一个对象,然后新实例化了另外一个对象,并把oid附上去了。
解决办法:
1. 在update之前调用session.clear().
2. 或者用merge方法去替换update方法