首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

net.sf.hibernate.NonUniqueObjectException:a different object with the

2014-01-26 
net.sf.hibernate.NonUniqueObjectException:a different object with the same identifier value was alre

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[]免得重复

        

热点排行