Take the 2-minute tour ×

We have the following mapping:

public class A {
    private B b;

    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?

share|improve this question
what is the error, and sql log? –  James Sep 27 '11 at 14:36

1 Answer 1

You should disable cascade delete

@OneToOne(cascade = {})

or you can try

share|improve this answer
Those options (empty cascade and orphanRemoval=false) are the defaults when you don't specify them on the @OneToOne annotation so I don't think this answer will do the trick. –  NBW Feb 26 at 14:53

Your Answer


