John Giotta
John Giotta

Reputation: 16964

How Do I Use HQL to SELECT Random Record from Table

I would like to use HQL to select a random record for a few integration tests.

I've been using SQL Server ORDER BY newid(), but HQL parsing likes to raise false alarms.

Upvotes: 0

Views: 3103

Answers (1)

carbontax
carbontax

Reputation: 2184

Hibernate does not provide a database independent way to do this. You have to do it in two queries.

See Get random object from SQL database via Hibernate

Upvotes: 1

Related Questions