HHH-16815 rename paginate() -> setPage
fix a bug in Page class
This commit is contained in:
parent
7227831d56
commit
73c8479bf4
|
@ -14,9 +14,9 @@ import org.hibernate.Incubating;
|
|||
* <p>
|
||||
* This is a convenience class which allows a reference to a page of
|
||||
* results to be passed around the system before being applied to
|
||||
* a {@link Query} by calling {@link Query#paginate(Page)}.
|
||||
* a {@link Query} by calling {@link Query#setPage(Page)}.
|
||||
*
|
||||
* @see Query#paginate(Page)
|
||||
* @see Query#setPage(Page)
|
||||
*
|
||||
* @since 6.3
|
||||
*
|
||||
|
@ -43,13 +43,17 @@ public class Page {
|
|||
return size*number;
|
||||
}
|
||||
|
||||
public Page(int size, int number) {
|
||||
private Page(int size, int number) {
|
||||
this.size = size;
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public static Page page(int size, int number) {
|
||||
return new Page( size, number );
|
||||
}
|
||||
|
||||
public static Page first(int size) {
|
||||
return new Page(0, size);
|
||||
return new Page( size, 0 );
|
||||
}
|
||||
|
||||
public Page next() {
|
||||
|
|
|
@ -888,15 +888,15 @@ public interface Query<R> extends SelectionQuery<R>, MutationQuery, TypedQuery<R
|
|||
@Override
|
||||
Query<R> setFirstResult(int startPosition);
|
||||
|
||||
@Override @Incubating
|
||||
default Query<R> paginate(int pageSize, int pageNumber) {
|
||||
setFirstResult( pageNumber * pageSize );
|
||||
setMaxResults( pageSize );
|
||||
return this;
|
||||
}
|
||||
// @Override @Incubating
|
||||
// default Query<R> setPage(int pageSize, int pageNumber) {
|
||||
// setFirstResult( pageNumber * pageSize );
|
||||
// setMaxResults( pageSize );
|
||||
// return this;
|
||||
// }
|
||||
|
||||
@Override @Incubating
|
||||
default Query<R> paginate(Page page) {
|
||||
default Query<R> setPage(Page page) {
|
||||
setMaxResults( page.getMaxResults() );
|
||||
setFirstResult( page.getFirstResult() );
|
||||
return this;
|
||||
|
|
|
@ -325,16 +325,16 @@ public interface SelectionQuery<R> extends CommonQueryContract {
|
|||
*/
|
||||
SelectionQuery<R> setFirstResult(int startPosition);
|
||||
|
||||
/**
|
||||
* Set the page of results to return.
|
||||
*
|
||||
* @param pageNumber the page to return, where pages are numbered from zero
|
||||
* @param pageSize the number of results per page
|
||||
*
|
||||
* @since 6.3
|
||||
*/
|
||||
@Incubating
|
||||
SelectionQuery<R> paginate(int pageSize, int pageNumber);
|
||||
// /**
|
||||
// * Set the page of results to return.
|
||||
// *
|
||||
// * @param pageNumber the page to return, where pages are numbered from zero
|
||||
// * @param pageSize the number of results per page
|
||||
// *
|
||||
// * @since 6.3
|
||||
// */
|
||||
// @Incubating
|
||||
// SelectionQuery<R> setPage(int pageSize, int pageNumber);
|
||||
|
||||
/**
|
||||
* Set the {@linkplain Page page} of results to return.
|
||||
|
@ -344,7 +344,7 @@ public interface SelectionQuery<R> extends CommonQueryContract {
|
|||
* @since 6.3
|
||||
*/
|
||||
@Incubating
|
||||
SelectionQuery<R> paginate(Page page);
|
||||
SelectionQuery<R> setPage(Page page);
|
||||
|
||||
/**
|
||||
* Obtain the {@link CacheMode} in effect for this query. By default,
|
||||
|
|
|
@ -276,15 +276,15 @@ public class SqmSelectionQueryImpl<R> extends AbstractSelectionQuery<R>
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// convenience methods
|
||||
|
||||
@Override
|
||||
public SelectionQuery<R> paginate(int pageSize, int pageNumber) {
|
||||
setFirstResult( pageNumber * pageSize );
|
||||
setMaxResults( pageSize );
|
||||
return this;
|
||||
}
|
||||
// @Override
|
||||
// public SelectionQuery<R> setPage(int pageSize, int pageNumber) {
|
||||
// setFirstResult( pageNumber * pageSize );
|
||||
// setMaxResults( pageSize );
|
||||
// return this;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public SelectionQuery<R> paginate(Page page) {
|
||||
public SelectionQuery<R> setPage(Page page) {
|
||||
setMaxResults( page.getMaxResults() );
|
||||
setFirstResult( page.getFirstResult() );
|
||||
return this;
|
||||
|
|
Loading…
Reference in New Issue