
com.github.fluent.hibernate.Pagination Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluent-hibernate-core Show documentation
Show all versions of fluent-hibernate-core Show documentation
A library to work with Hibernate by fluent API. This library hasn't dependencies except Hibernate dependencies. It requires Java 1.6 and above.
package com.github.fluent.hibernate;
import org.hibernate.Criteria;
/**
* Pagination parameters.
*
* @author V.Ladynev
*/
public class Pagination {
public static final Pagination EMPTY = new Pagination(0, 0);
/** Page index, begins from 0. */
private final int pageIndex;
/** Objects on page count. */
private final int pageSize;
public Pagination(int pageIndex, int pageSize) {
this.pageIndex = pageIndex;
this.pageSize = pageSize;
}
public void addToCriteria(final Criteria criteria) {
if (this == EMPTY) {
return;
}
criteria.setMaxResults(pageSize);
criteria.setFirstResult(pageIndex * pageSize);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy