-->
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: Random number of rows from oracle table using Hibernate ?
PostPosted: Wed Apr 23, 2008 8:26 pm 
Newbie

Joined: Mon Mar 31, 2008 2:37 pm
Posts: 6
Location: Seattle
Hibernate version: 3.2.3
Name and version of the database you are using: Oracle 10.2

How to get randomly selected rows which matched the where clause from an oracle table using Hibernate ?

Is there a way to use Hibnerate to get random rows from the resultset.
Example: Table of size N records, out of which M matched my where clause and i want 10 random records out of M.

In MySql, we can do it by order by rand(), but could not find an alternative in Oracle.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2008 12:45 am 
Newbie

Joined: Wed Dec 17, 2008 3:11 am
Posts: 2
Location: India
Here it is..

SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum = 1

_________________
--
Best Regards
Sharaf


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.