I'm using Hibernate 3.3.2. I have class A, which has a property b, which maps a many-to-many relation to B.
Class A has the following mapping:
<set name="b" table="a_b" lazy="true">
<key column="id_a"/>
<many-to-many class="B" column="id_b" outer-join="auto" />
</set>
I am trying the following:
Criteria c = HibernateUtil.getSession().createCriteria(A.class);
ProjectionList pl = Projections.projectionList();
pl.add(Projections.property("id_a"), "id_a");
pl.add(Projections.property("b"), "b");
c.setProjection(pl);
c.add(Restrictions.eq("id", id));
Object o = c.list();
This code doesn't load any instance of B; the element corresponding to b in the returned ArrayList is null. Do you have any idea?
Thanks.