I have two classes with bidirectional matching @OneToOne to each other.
Class A {
@OneToOne(fetch = FetchType.Lazy, mappedBy="a")
private B b;
}
Class B {
@OneToOne(fetch = FetchType.Eager)
private A a;
}
I need to write code to retrieve all copies B, for which there is no instance of A, associated with them. I also need to write a similar request for all A, which do not B.
I tried:
Criteria criteria = getSession().createCriteria(B.class)
criteria.add(Restrictions.isNull("a")
but it always returns null. Thoughts?
source
share