Combine
http://stackoverflow.com/questions/4414964/how-to-get-list-of-10-random-unique-objects-with-hibernate
with
http://stackoverflow.com/questions/580639/how-to-randomly-select-rows-in-sql

I.e. append "order by xxx()", where xxx is what the database you're
using knows.

rand() seems to work for both mysql and hsqldb.

On 07/17/2014 04:54 PM, Danilo Oliveira wrote:
> Hello XWiki Devs,
> 
> I have a specific class in the XWiki (TestClass) with more than 50 items.
> However I would like to retrieve, through the HQL statement, just 5 random
>  results.
> 
> I know how to set the limit, using the "setlimit", however I don't know and
> I did not find if there is a way to retrieve a random result.
> 
> Is it possible, or I will need to make a hql that returns all results and
>  after that take  5 itens randomly?
> 
> Thanks
> 


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to