Hibernate version: 3.2.6.ga
I have two classes, A and B.
Code:
public class A
{
private Set<B> b = new Hashset<B>(0);
}
public class B
{
...
}
Mapped as following:
In A.hbm.mxl
<set name="b" lazy="true">
<key column="b_fk"/>
<one-to-many class="B"/>
</set>
In B.hbm.xml:
<many-to-one name="a" class="A" column="b_fk">
</many-to-one>
I have a hql query:
Select a
From A a inner join a.B b
where b.(lots of trivial conditions on 'b').This gives me a list of A's in my dao. However, as the relationship bertween A and B is lazy; B is not initialised.
I can't iterate through the list and use Hibernate.initialise as this would ignore the conditions in the hql.
I know I could change the hql and get it to bring back on Object[] containing A and B but I wanted to get the B's through a.getB();
In my Dao:
Code:
Query query =
aSession.getNamedQuery(myQueryName);
List<A> results = query.list();
Is there a way to initialise the B's from inside the hql, whilst still bringing only a List of A's back?