I am testing the criteria for narrowing collection items being loaded.
Entity A has a collection of entity Bs. There are 2 ways references between A and B. The fetch type is LAZY for both relationships.
In my loading code, I have the following criteria defined:
Code:
Criteria criteria = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(EntityA.class)
.add(Restrictions.eq("id", primaryKey))
.createCriteria("entityBs")
.add(Restrictions.eq("state", 1));
List<EntityA> entityAs = criteria.list();
Hibernate loads correct EntityA but it does not load any EntityBs.
I run the generated query and it does return values for both EntityA and EntityB.
Anyone knows what the problem is?