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.  [ 3 posts ] 
Author Message
 Post subject: How to limit the number of raws returned by a query?
PostPosted: Fri Oct 17, 2003 5:59 am 
Newbie

Joined: Wed Sep 03, 2003 4:59 am
Posts: 12
I would like to know how to limit the number of raws returned by a query and what kind of syntax should I use...

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 9:25 am 
Regular
Regular

Joined: Tue Aug 26, 2003 3:34 pm
Posts: 54
Location: Farroupilha - Brasil
I think you can use Query.scroll() method. Look at

http://www.hibernate.org/hib_docs/reference/html/manipulating-data.html#manipulating-data-s5b


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 9:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at the 7.3.2 reference guide section
Quote:
If you need to specify bounds upon your result set (the maximum number of rows you want to retrieve and / or the first row you want to retrieve) you should obtain an instance of net.sf.hibernate.Query:


Code:
Query q = sess.createQuery("from DomesticCat cat");
q.setFirstResult(20);
q.setMaxResults(10);
List cats = q.list();


Beware of setting setFirstResult > 0 to use SQL LIMIT stuffs of your underlying DB.
http://forum.hibernate.org/viewtopic.php?t=924462&highlight=setfirstresult


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.