Hi everybody,
I have a currently a bidirectional relation one-to-one. I want lazy loading for my one-to-one relation
See under the example:
Code:
class A {
@OneToOne(fetch=FetchType.LAZY, cascade=Cascade.ALL, mappedBy="a")
B b;
}
class B {
@OneToOne(fetch=FetchType.LAZY, optional="false")
A a;
}
I do not want in my case to load the object A when I am loading an object B.
In my understanding of Hibernate, the relation cannot be lazy loaded if the object A contained in B can be null. When we specify optional=false, it means that we ensure that we cannot have null value and Hibernate is therefore able to create a proxy for A when it is loading B.
Can somebody tell where I am wrong because this solution is not working for me ?
Thanks in advance,
Tiggy