Possible Duplicate:
Spring + Hibernate : a different object with the same identifier value was already associated with the session休眠 - 用相同的標識符值不同的物體已經與所述會話
相關聯從
@Id
private int getId(){
return this.id;
}
改變實體的@id
到
@Id
private String getLogin(){
return this.login;
}
後我收到錯誤:
a different object with the same identifier
value was already associated with the session
在web應用程序中沒有改變任何東西。讀取實體,然後更改表單中的某些字段,然後提交後,我嘗試保存或更新實體。隨着int
爲@Id
沒有問題,但現在隨着String
爲@Id
我通過更新得到上述錯誤或保存實體:
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void saveOrUpdate(User u) {
getHibernateTemplate().saveOrUpdate(u);
}
可能是什麼問題呢?
顯示會話中的代碼可能會有所幫助。 – samitgaur 2010-07-17 04:31:32