Select top 1 from <tablename>
what is hql query for the above ?
Select top 1 from <tablename>
what is hql query for the above ?
It seems you must use the setMaxResults()
method.
See for example this question+answer : How do you do a limit query in HQL
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();
You'll probably want to use the setMaxResults of the Query Object.
To my knowledge, HQL does not support top or limit.