开发者

Delete OneToOne relationship

We have the following mapping:

@Entity
public class A {
    private B b;

    @OneToOne
    public B getB() {
        return b;
    }
}
开发者_运维问答

When we delete an object of class A it must not delete the referenced object B. At the moment we get an exception when we try to delete A because of the existing relationship to B. How is the correct mapping?


You should disable cascade delete

@OneToOne(cascade = {})

or you can try

@OneToOne(orphanRemoval=false)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜