|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.geekologue.md4j.dao.hibernate.HbmQueryResultPage
public class HbmQueryResultPage
Hibernate-based implementation of the Page interface. Used by Hibernate-based DAOs to page Hibernate Queries, Criteria Queries as well as POJO collection references.
Paging a query is as simple as:
Page page = new HbmQueryResultPage(session, session .createQuery("from Type obj order by obj.prop desc"), pageNumber, maxResults);
Which will only load maxResults+1 objects from the database. You can also page a collection like:
Page page = new HbmQueryResultPage(session, object.getChildren(), pageNumber, maxResults);
Constructor Summary | |
---|---|
HbmQueryResultPage(org.hibernate.Criteria query,
java.util.Set projectionProps,
int number,
int size)
Constructor that will page a criteria query without loading all results |
|
HbmQueryResultPage(org.hibernate.Query query,
int number,
int size)
Constructor that will page a query without loading all results |
|
HbmQueryResultPage(org.hibernate.Session session,
java.util.Set collection,
int number,
int size)
Constructor that will page a collection. |
Method Summary | |
---|---|
int |
getFirstResultIndex()
Get the index of the first result in the page |
int |
getLastResultIndex()
|
java.util.List |
getList()
Get the page of results as the list |
int |
getNext()
|
int |
getPageNumber()
Get the page number |
int |
getPageSize()
return pageSize The page size |
java.util.Map |
getParentOptions()
|
int |
getPrevious()
|
int |
getTotalPageCount()
Get the total number of pages that can be used to divide the total results using the current page size. |
int |
getTotalResultCount()
|
boolean |
isFirst()
See if this page is the first |
boolean |
isLast()
See if this page is the last |
void |
setList(java.util.List newList)
Set the list of results for this page. |
void |
setParentOptions(java.util.Map opts)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HbmQueryResultPage(org.hibernate.Query query, int number, int size)
session
- The hibernate session that created the queryquery
- The query with any (named or positional) parameters already
setnumber
- The page number (1,2,3...n)size
- The number of entries a page should containpublic HbmQueryResultPage(org.hibernate.Criteria query, java.util.Set projectionProps, int number, int size)
session
- The hibernate session that created the queryquery
- The criteria querynumber
- The page number (1,2,3...n)size
- The number of entries a page should containpublic HbmQueryResultPage(org.hibernate.Session session, java.util.Set collection, int number, int size)
session
- The Hibernate Session to usecollection
- The collection to page, e.g.: foo.getBars();pageNumber
- The page number (1,2,3...n)pageSize
- The number of entries a page should contain
org.hibernate.HibernateException
Method Detail |
---|
public int getTotalResultCount()
getTotalResultCount
in interface Page
public int getTotalPageCount()
getTotalPageCount
in interface Page
public boolean isFirst()
isFirst
in interface Page
public boolean isLast()
isLast
in interface Page
public java.util.List getList()
getList
in interface Page
public int getPageNumber()
getPageNumber
in interface Page
public int getFirstResultIndex()
getFirstResultIndex
in interface Page
public final int getPageSize()
public final int getLastResultIndex()
public final int getNext()
public final int getPrevious()
public void setList(java.util.List newList)
Page
getList()
setList
in interface Page
newList
- the list of results to set for this pagepublic java.util.Map getParentOptions()
getParentOptions
in interface Page
Page.getParentOptions()
public void setParentOptions(java.util.Map opts)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |