| I cannot reproduce it with your test. I changed the test to this:
@Test
public void testGetByParentIdLazy() throws Exception {
CategoryDAO<Category> categoryCategoryDAO = new CategorySqlHibernateDAO();
prepare();
List<Category> result = categoryCategoryDAO.getByParentIdLazy(0);
Assert.assertTrue(result.size() == 1);
}
and Hibernate generates this query:
select
category0_.categoryId as category1_0_,
category0_.categoryName as category2_0_,
category0_.categoryImage as category3_0_,
category0_.categoryParentId as category4_0_
from
Category category0_
where
categoryParentId=?
So only one query is executed. If fetch lazy was broken, they you'd see two queries or a self-join, right? |