-->
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 can I limit a query (use of Oracle rownum)
PostPosted: Wed Oct 01, 2003 11:58 am 
Newbie

Joined: Wed Oct 01, 2003 11:00 am
Posts: 1
I am using Hibernate with a Datasource on Oracle and I would like to limit the number of rows retrieved by a select statement but on Oracle side.

I tried with the following statement but it failed:

Code:
Session.find("SELECT * from (myhibernatequery) where rownum<100)");



It works with Query.setMaxResults() but this is not performed by Oracle.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 5:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ummmm we actually use this kind of query when you use setFirstResult() > 0 .... I've never been certain if we should use it in the case of ONLY a setMaxResults(). I'm not sure if its better.

Add a request to JIRA if you like ..... but I will need some solid advice on this before changing anything.


Top
 Profile  
 
 Post subject: Sould be documented ?
PostPosted: Thu Oct 02, 2003 4:46 am 
Newbie

Joined: Thu Sep 18, 2003 8:37 am
Posts: 3
Umm, perhaps this behaviour needs to be documented somewhere in the chapter regarding performance and optimization, coz it's not obvious by simply looking at the javadoc.

BTW, what would be the impact of letting setMaxResult() limit the size of the underlying SQL query without having to setFirstResult()>0 ?

Laurent


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.