Announcement Announcement Module
Collapse
No announcement yet.
limiting results in Hibernate? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • limiting results in Hibernate?

    How do I return result 0-25, 26-50, 51-75 etc....

  • #2
    Check out the Hibernate JavaDocs for the Query interface - it talks about paging using setMaxResults and setFirstResult.

    Rob

    Comment


    • #3
      Watch out for crappy database queries. Hibernate translates pagination for Ms Sql to a select top query. So if you need 9.900 to 10.000 you will get 10.000 records and not 100. This could be a serious performance problem.

      Comment


      • #4
        But what on the HibernateTemplate am I suppose to use?
        I am using Hibernate solely through the Spring Hibernate templates.

        Originally posted by robh
        Check out the Hibernate JavaDocs for the Query interface - it talks about paging using setMaxResults and setFirstResult.

        Rob

        Comment


        • #5
          Originally posted by mickknutson
          But what on the HibernateTemplate am I suppose to use?
          I am using Hibernate solely through the Spring Hibernate templates.
          You have to create a session somewhere so you can create a Criteria/Query/SqlQuery that can be executed to retrieve the information.


          For more information see:
          http://www.hibernate.org/hib_docs/ap.../Criteria.html

          And check the
          setMaxResults(int maxResults)
          setFirstResult(int firstResult)

          to use pagination.

          Comment


          • #6
            Read the following section of the Spring reference guide:

            11.2.3. Inversion of Control: HibernateTemplate and HibernateCallback

            http://static.springframework.org/sp...m.html#d0e6874

            Comment

            Working...
            X