我有某種Hibernate的bug,可能很簡單,但我無法解決它。我正在使用彈簧&休眠& MS SQL。 我有一個Employee對象A,我選擇從列表中進行編輯。如果我在一個選項卡中打開該員工A,然後在另一個選項卡中打開員工B.如果我在B仍然打開的情況下提交Employee A,它會將數據從A保存到B - 覆蓋B. 我看過我的Equals & Hashcode,我有一個Version列,甚至試圖搞亂SQL的隔離級別。我還沒有弄明白。這成爲一個主要問題,因爲用戶經常會同時打開兩個員工以便從一個人複製到另一個人。我不使用註釋併爲我的映射使用java + hbm文件。 這裏是我的equals &哈希碼休眠 - 2打開窗口記錄覆蓋其他
public boolean equals(Object other) {
if ((this == other)) {
return true;
}
if (!(other instanceof Employee)) {
return false;
}
Employee castOther = (Employee) other;
return this.userLogin.equals(castOther.getUserLogin());
}
public int hashCode() {
return new HashCodeBuilder().append(this.getUserLogin()).toHashCode();
}
下面是我的HBM我的版本聲明
<version name="version" column="VERSION" unsaved-value="negative" />
否 - 根本沒有Cookie – 2012-04-02 20:52:26