Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Hibernate Pagenation, Updating The Setfirstresult Parameter

hibernate pagenation

  • Please log in to reply
1 reply to this topic

#1 mctim

mctim

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 29 July 2012 - 06:55 PM

I'm trying to implement some pagination using hibernate. Here's a website that discusses how to do that. I understand how I can do this to set the first row that I want to query for x number of entities. What I'm having trouble understanding is how to update the setFirstResult parameter so that I end up with all the entities in the db that match my query. What do I need to do inorder to update this parameter so I eventually get all the "pages"
  • 0

#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 30 July 2012 - 01:01 AM

You mean this?

Query query = session.createQuery("from Studenet s");
query.setFirstResult((page-1)*amountPerPage);
query.setMaxResults(amountPerPage);


  • 0





Also tagged with one or more of these keywords: hibernate, pagenation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download