The following two methods return different number of objects. The one done by criteria returns duplicates objects for one row in the table about in the middle of the table. I do not understand why these are returning different results.
Code:
public List<Category> findCategoriesSortedByLft()
{
return (List<Category>) getHibernateTemplate().execute(new HibernateCallback()
{
public Object doInHibernate( Session session )
{
Criteria criteria = session.createCriteria(Category.class);
criteria.addOrder(Order.asc("lft"));
return criteria.list();
}
});
}
public List<Category> findCategoriesSortedByLft1()
{
String query =
"from Category c " +
"order by c.lft";
return (List<Category>) getHibernateTemplate().find(query);
}