net.sf.hibernate.NonUniqueObjectException:a different object with the same identifier value was already associated with the session
是在使用
for(int i...)
session.load(obj[i],key[i]);
时,出现这样的错误,key[0],key[1],key[2]...有可能是相同的字符串,因此取出的obj[i]也可能是相同的对象,这样做就不行吗?有什么办法可以解决吗?
------解决方法--------------------------------------------------------
对象标识不唯一.应该在load之前判断出相同的对象标识,只装载不同的对象.
------解决方法--------------------------------------------------------
用HashMap代替key[]免得重复