The_Game wrote:
I think I might have realized what the mistake is. The above criteria query generates a sql query similar to this
SELECT * FROM lang WHERE ROWNUM=1 ORDER BY SORT_ORDER ASC;
This query always returns the same row, no matter how it is sorted (because ROWNUM=1 always returns the first row). sql then tries to sort the single row :)
Please, correct me if I am missing something. Thanks.
I take it, you're using Oracle. Then your assumption is correct.
Oracle narrows the resultset by applying the where condition. These results are sorted afterwards.
You might be able to do what you want another way:
Try setMaxResults(1) instead of ROWNUM=1.