0
可能重复:
Hibernate: different object with the same identifier value was already associated with the sessionHibernate对象的平等检查
据我了解(纠正我,如果我错了)Hibernate使用对象引用检查对象平等。当Hibernate确定有多个对象附加到同一个数据库记录时,它会抛出以下异常。
"a different object with the same identifier value was already associated with the session"
我的问题是,不使用Hibernate equal()
方法来检查对象的相等(默认等于方法使用对象引用)?如果是这样,重写equal()
方法会改变Hibernate的行为吗?
注意:我的问题不是关于Hibernate持久化对象中的issues of implementing equal()
or hashCode()
方法。
谢谢。