Hibernate version: 3
I posted a similar message yesterday titled "Hibernate and Proxies" which has not received any comment, so I will try and refrase it here.
I am trying to set up two classes with a one-to-one relationship between them:
Code:
ClassA
ClassB
ClassA should have a one-to-one two ClassB. Where the relationship should be proxied. However everytime I read an instance of ClassA from Hibernate, it also reads the relationship to ClassB.
In my mapping file for ClassA, I have the following:
<one-to-one name="classB" class="ClassB"
fetch="select" lazy="proxy"/>
Now: when I execute:
Code:
ClassA classA = session.load(ClassA.class, id);
classA.getName();
When #getName() is executed, Hibernate executes the SQL to get the ClassA instance "classA", but also executes a second SQL to get a ClassB instance !
Why is there not a proxy generated and the SQL only executed when I call something like:
Code:
classA.classB;
?
Many thanks
Ian