开发者

JPA 2.0 BI directional one-to-one mapping merge

开发者 https://www.devze.com 2023-02-19 17:47 出处:网络
I am using JPA 2 with hibernate as the vendor. I have 2 entities, Group and GroupFilter. I have a one-to-one bidirectional mapping between them with a join column in GroupFilter referencing Group. Whi

I am using JPA 2 with hibernate as the vendor. I have 2 entities, Group and GroupFilter. I have a one-to-one bidirectional mapping between them with a join column in GroupFilter referencing Group. While saving Group, the GroupFilter gets persisted. However, when i try to update Group using merge, i get - org.hibernate.TransientObjectException: object references an unsaved transient instance

While persisting group, 开发者_如何转开发i need to set both relations explicitly. Using the mappedBy attribute on Group, the order of save is that Group gets persisted 1st, and then GroupFilter. But in the case of merge, i think it happens the other way around. (cascade = ALL).

Any suggestions on this?

0

精彩评论

暂无评论...
验证码 换一张
取 消