Does anyone have HQL query on how to get list of 10 random unique objects from the database?
It should be done in database not in application. I'd like to get something that has better performance than my current solution which pretty much makes 10 requests to get the list filed up.
HQL would be something like:
session.createQuery("select o from Object o order by rand()")
.setMaxResults(10)
.list()
The rand() is passed through to the database so replace this with whatever function your database uses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With