activity6分页查询,listPage的参数
源码:
/**
* Describes basic methods for querying.
*
* @author Frederik Heremans
*/
public interface Query<T extends Query<?, ?>, U extends Object> {
/**
* Order the results ascending on the given property as defined in this class (needs to come after a call to one of the orderByXxxx methods).
*/
T asc();
/**
* Order the results descending on the given property as defined in this class (needs to come after a call to one of the orderByXxxx methods).
*/
T desc();
/** Executes the query and returns the number of results */
long count();
/**
* Executes the query and returns the resulting entity or null if no entity matches the query criteria.
*
* @throws ActivitiException
* when the query results in more than one entities.
*/
U singleResult();
/** Executes the query and get a list of entities as the result. */
List<U> list();
/** Executes the query and get a list of entities as the result. */
List<U> listPage(int firstResult, int maxResults);
}
firstResult指的是第一条,并不是第几页,
第几条就像mysql分页一样,重0开始,maxResults就像pageSize,重0开始往后第10条.
第二页则是(2-1)*10 ,10 就是重第十条开始,往后第十条.
所以应该写为:(pageNum - 1) * pageSize, pageSize
世界上所有的不公平都是由于当事人能力不足造成的.