How can I execute this below native query in a DAO class which extends
org.springframework.orm.hibernate3.support.HibernateDaoSupport
Native Query :
select * from mytable where key="abcd" and id = 111 order by rank asc limit 10 offset 20
Updated:
List list =(List) getHibernateTemplate().find(sql); return list;
My query was this, here I am not getting the results by according to the conditions
You can not put limit and offset in hql.There is a way around.Try the following query,
Query query=session.createQuery("from mytable mt WHERE mt.key='abcd' AND mt.id=111 ORDER By mt.rank ASC")
.setFirstResult(20)
.setMaxResults(10);
In hibernate setFirstResult and setMaxResults are used instead of OFFSET and LIMIT.