lokesh pattajoshi wrote:HI every body i am using this query to get single value from data base but it is returning multiple values.I know setFirstResult and setMaxResult but except that can we use other things directly in hql.
select count(S.humanID) from Human S,Animal W WHERE S.humanID=W.animalID group by S.humanID order by count(S.humanID) desc limit 0,1
There is no database independant way to express the FirstResult/MaxResult semantic in SQL. So there is no way you can do it via HQL. setFirstResult/setMaxResults will be translated into LIMIT x,y for MySQL Dialect. But the sql for other databases is totally different (e.g. "fetch first x rows only" for DB2).
If you except a single row result but you get mulitple rows than
you should re-think your statement. It might be wrong.