-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: setMaxResults and setFirstResult in Hibernate2
PostPosted: Wed Oct 29, 2003 7:57 am 
Newbie

Joined: Thu Sep 25, 2003 9:25 am
Posts: 15
I just updated my application to use Hibernate 2. Everything works just fine except ONE query, which is as follows:

Code:
Query q = session.createQuery("from a in class A where a.name=? order by a.created desc");
q.setString(0, myName);
q.setFirstResult((pageNum - 1) * pageSize);
q.setMaxResults(pageSize);
myList = q.list();


If pageNum is 1 (ie. firstResult is set to 0) the query returns the rows just fine, but when the pageNum is > 0, it returns an empty list.

And I know there ARE rows it should return, because if I set maxResults to eg. 100 the query returns all the rows (currently 22 in the DB), but with anything less that 22 (and firstResult > 0), the query returns an empty list.

The query worked OK with Hibernate 1, I have made no changes to the query. The DB I use for this application is Oracle.

Thanks!


Top
 Profile  
 
 Post subject: Problem solved
PostPosted: Wed Oct 29, 2003 8:21 am 
Newbie

Joined: Thu Sep 25, 2003 9:25 am
Posts: 15
Upgraded to version 2.0.3 and now the query works just fine!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.