tags:

views:

124

answers:

3
Select top 1 from <tablename>

what is hql query for the above ?

+2  A: 

It seems you must use the setMaxResults() method.

See for example this question+answer : How do you do a limit query in HQL

Pascal MARTIN
+4  A: 

Just write a normal query, ans use "SetMaxResult" to limit your results.

I.e.

return  getSession().createQuery("from items order by id asc")
            .setMaxResults(1)
            .list();
Marcos Placona
+1  A: 

You'll probably want to use the setMaxResults of the Query Object.

To my knowledge, HQL does not support top or limit.

tschaible