I have a spring MVC application, how can I return a list of users and limit the results?
My UserDao looks like:
public List<User> getUsers(int limit) {
return super.getHibernateTemplate()????
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m assuming you’re doing this for purposes of paging.
You can create a Query and use setMaxResults and setFirstResult:
Alternatively, use a HibernateCallback (this is probably the best method, although it’s wordier):
Which will additionally take care of exception translation for you.