I have some problems with the Hibernate criteria API. I want to get rows of a table as objects, but limit the amount of returned results. Here is the code:
Criteria c = session.createCriteria(User.class);
c.setFirstResult(start);
c.setMaxResults(end-start);
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
List<User> test = c.list();
First result is in my case 0 and max results 10. There are 3 users in the db. The problem is that only the first row of the database is in the result list. If I don't use the resultTransformer, the first row is 10 times (maxResults) in the list. If i dont't use max results and resultTransformer, the first row is about 100 times in the result list.
If I add an restriction for a specific user, the result list contains the specific user, so this it is clear that not only the first row could be found because of some strange circumstances.
Please help, I'm clueless.