Can't explain why this produces the correct results of [1000,2000,3000]
Code:
Item item = (Item) HibernateUtils.getSessionFactory().getCurrentSession().createCriteria(Item.class)
.add(Restrictions.eq("id", 12345L))
.setFetchMode("categories", FetchMode.JOIN)
.setReadOnly(true)
.uniqueResult();
for (ItemCategory category : item.getCategories()) {
System.out.println(category.getCategoryId());
}
But this doesnt included all of the categories and only produces [1000]
Code:
ScrollableResults results = HibernateUtils.getSessionFactory().getCurrentSession().createCriteria(Item.class)
.add(Restrictions.eq("id", 12345L))
.setFetchMode("categories", FetchMode.JOIN)
.setReadOnly(true)
.scroll();
results.next();
Item item = (Item) results.get(0);
for (ItemCategory category : item.getCategories()) {
System.out.println(category.getCategoryId());
}
Can someone explain what is going on here? Thanks