Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Normally for a function that displays large amount of records in the table format ,in order to consume less memory, the records will be shown page by page just like the <a href="http://stackexchange.com/leagues/week/stackoverflow">Stackoverflow reputation league</a> </p> <p>Hibernate 's <code>Criteria</code> and <code>Query</code> API provides the following functions to do the pagination:</p> <ul> <li><a href="http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/Query.html#setMaxResults%28int%29" rel="nofollow">setMaxResults(int maxResults)</a> to limit the number of the row to be retrieved </li> <li><a href="http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/Query.html#setFirstResult%28int%29" rel="nofollow">setFirstResult(int firstResult)</a> to set the first row number to be retrieved (ie. 0 means first row)</li> </ul> <p>In the JTable , you should has the variables for storing the number of records shown per page (<code>pageNum</code>) and the current page number (<code>pageNum</code>). Whenever user changes the <code>pageNum</code> by navigating the page forward or backward , you fetch the records for this page: </p> <pre><code>Query q = entityManager.createQuery("from someTable tbl order by tbl.id asc"); q.setFirstResult((pageNum -1)*pagesize).setMaxResults(pagesize); </code></pre> <p>Important Points:</p> <ul> <li>Without the "order by" clause , the order of the fetched row is unpredictable . So , it is important that the query has to be sorted by the "order by clause" such that the displaying order of the records can be maintained when the page is browsed forward and backward . </li> </ul> <p>You can refer to <a href="http://martinusadyh.web.id/2011/01/31/paging-on-jtable/" rel="nofollow">this</a> (Use Google translate to translate to English) and its <a href="https://github.com/martinusadyh/artivisi-farm-server/tree/master/table-paging" rel="nofollow">Github</a> for an example about JTable pagination using Hibernate or JDBC. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload