I have the same issue but the child is loading eagerly in separate select statements for no reason. What are lazy="no-proxy" and lazy="proxy" for then?
I have a user and user_termination tables with only the user_termination having the user_id as the foreign key and the user may or may not have a user_termination entry!
I defined the userTermination mapping in user as
Code:
<one-to-one name="userTermination" class="UserTermination"
property-ref="user" lazy="no-proxy">
</one-to-one>
And the userTermination has a user entry as a many-to-one
Code:
<many-to-one name="participant" class="Participant" column="participant_id" unique="true" not-null="false" />
I chose lazy="no-proxy" in my parent however, whenever I write my HQL on parent User table such as
Code:
from User user where user.user_deleted_date_time is null
it fetches all of my user's first in a single select and then follows by a separate select statements of userTermination, obviously whenever they may only exist, although I don't need them to be fetched eagerly unless I do a left join fetch or something!
There is no alternative by avoiding the userTermination entry in user object and write my HQL query as select from user, userTermination where
user.userId = userTermination.userId it looses the user objects as only not all users have userTermination!!
In a normal SQL statement all I have to do is a left join as in
select .. from user, userTermination where user.userId = userTermination.userId(+)
I am not sure if I can write my left join HQL query without having it to be mentioned as a one-to-one object in my parent mapping?
Any suggestions?
Regards
Rama