org.hibernate.NonUniqueObjectException

来源:互联网 发布:淘宝第二层级 访客数 编辑:程序博客网 时间:2024/05/01 00:38

org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.xie.hibernate.modal.Org#2]

 

非唯一对象异常,这是因为:在hibernate实体类中加上了@GeneratedValue,同时还在生成对象时手动给id赋值,在向数据哭中存放数据记录时,就发生了这个异常。手动给id赋值,而hibernate又自动生成了id,产生冲突。解决办法:不要手动赋值id就可以了。

原创粉丝点击