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)
精彩评论