更新我有一個看起來像這樣的實體:場與@Transient註釋數據庫
@Entity
public class Candidate {
...
@Transient
private JobApplication mostRecentApplication
...
}
@Entity
public class JobApplication{
...
@ManyToOne
private Candidate candidate;
...
}
爲了返回Candidate
作爲JSON對象時,以消除循環引用,我設置了Candidate
到null
在Candidate
中包含的JobApplication
。但是,如果我堅持已經更新的Candidate
,它會使用null
Candidate
更新JobApplication
,從而終止關聯。這是一個錯誤還是我做錯了什麼?我的印象是,JPA提供商應該忽略用@Transient.
註解的字段,我在Spring數據中使用了Hibernate。
如果您在候選事務上下文中將候選者設置爲空,則會將更改提交到數據庫 –