Hibernate version:
3.0.5 & 3.1rc2
Code between sessionFactory.openSession() and session.close():
Code:
Criteria criteria = session.createCriteria(Customer.class);
criteria.add(Restrictions.idEq(id));
criteria.setFetchMode("orders", FetchMode.SELECT); // has no effect
Customer customer = (Customer)criteria.uniqueResult();
I would expect that all Orders of the Customer are "eagerly" fetched in a second select. But it makes no difference, if FetchMode.SELECT is set or not.
A possible workaround is executing either Hibernate.initialize(customer.getOrders()) or customer.getOrders().size() but this is not practical for more complex graphs.
The same query also works fine with a FetchMode.JOIN.