I am trying to use the new StatelessSession.
When using hql and a
join fetch from parent to child, both the parent and child are fully initialized.
However, when using hql and a
join fetch from child to parent, the child is initialized, but the parent remains a
Proxy.
It appears that the hql is
not overriding the default
lazy="proxy" setting in the many-to-one mapping when using StatelessSession. It does work as expected when using Session.
Regards,
Gregg
Hibernate version:
3.1.2
Mapping documents:
Code:
<set name="Children" table="Child" inverse="true" cascade="all">
<key column="ParentFK"/>
<one-to-many class="Child"/>
</set>
<many-to-one name="Parent" column="ParentFK" class="Parent" cascade="none"/>
Code between sessionFactory.openSession() and session.close():Code:
String hql1 = "select parent from Parent parent join fetch parent.Children";
List results1 = MyStatelessSession.executeHQL(hql1);
// Results will have parent and children fully initialized
String hql2 = "select child from Child child join fetch child.Parent"
List results2 = MyStatelessSession.executeHQL(hql2);
// Results will have child fully initialized but parent is a Proxy.