views:

123

answers:

2

currently I am using the following to pull rows from a table called Table:

return getHibernateTemplate().find("from Table");

How do I use hibernate to pull only the first n rows from the table (i.e. like a mySql limit would do)?

Thanks.

Update: so is this the proper way to do it?

getHibernateTemplate().setMaxResults(35);
return getHibernateTemplate().find("from Table");
+2  A: 

Use HIbernateTemplate setMaxResults to limit the results.

Teja Kantamneni
Is the code that I updated in my question the proper way to do it?
es11
A: 

I ended up using a Hibernate Criteria query to do this and it works properly. I made use of the setFirstResult() and setLastResults() methods.

es11