-->
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: Using rownum with Hibernate
PostPosted: Thu Aug 10, 2006 10:33 am 
Newbie

Joined: Thu Jul 27, 2006 10:35 am
Posts: 16
Hi All

I am using Hibernate version2

I have a situation where in I am retreiving a list of few records. But I just want the first record from the list.

Normally in plain Oracle SQL query I would do something like this

SELECT * FROM
(SELECT * FROM employees ORDER BY employee_id)
WHERE ROWNUM < 2;

How can I replicate this using Hibernate createSQLQuery.

I reckon this way of doing a TOP-n query is not understood by Hibernate.


Do post your suggestions on the same


Regards,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 11:40 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Does Hibernate2 have this method in Query interface?
Code:
public Query setMaxResults(int maxResults)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 1:20 pm 
Senior
Senior

Joined: Tue Mar 09, 2004 2:38 pm
Posts: 141
Location: Lowell, MA USA
ROWNUM is supported in HQL, so you can use it just as you would in SQL.

Ryan-

_________________
Ryan J. McDonough
http://damnhandy.com

Please remember to rate!


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.