0
我有,我把的UniqueConstraint註解@UniqueConstraints失敗的更新
@Table(uniqueConstraints={@UniqueConstraint(columnNames={"staffRecord_id", "defaultLabel_id","company_id","keyCode"})})
public class AllowanceDeduction implements Serializable{
---
我已經注意到了,就是當我嘗試以節省使用
if (allowanceDeduction.getId() == null) {
this.entityManager.persist(allowanceDeduction);
} else {
this.entityManager.merge(allowanceDeduction);
}
when the save or update fails due to a unique constraint. Isn't it only supposed to fail when trying to save a new record that is identical to a record that already exist.
爲什麼表 一個實體類嘗試合併或更新時會失敗嗎? 請幫助需要