I have an entity DepartmentEmployee and lazy property department there:
Code:
@ManyToOne (fetch = FetchType.LAZY)
Department department;
For geting department list I use Criteria:
Code:
Criteria cr = session.createCriteria(DepartmentEmployee.class);
cr.setFetchMode("department", FetchMode.JOIN);
cr.add(Restrictions.eq("somekey", "somevalue"));
cr.setProjection(Property.forName("department") );
result = cr.list();
But Department object in this list still lazily initialized.
So why FetchMode.JOIN doesn't work?