hibernate/hibernate-orm · error · IllegalArgumentException

page size must be strictly positive

Error message

page size must be strictly positive

What it means

Error "page size must be strictly positive" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/Page.java:90

	 * @return the page {@linkplain #size}, that is, the
	 *         {@linkplain SelectionQuery#getMaxResults()
	 *         maximum number of results} on the page.
	 */
	public int getMaxResults() {
		return size;
	}

	/**
	 * @return the {@linkplain SelectionQuery#getFirstResult()
	 *         offset} of this page.
	 */
	public int getFirstResult() {
		return size*number;
	}

	Page(int size, int number) {
		if ( size <= 0 ) {
			throw new IllegalArgumentException("page size must be strictly positive");
		}
		if ( number < 0 ) {
			throw new IllegalArgumentException("page number must be non-negative");
		}
		this.size = size;
		this.number = number;
	}

	/**
	 * Obtain a page, numbered from {@code 0}, with the given size.
	 * @param size the number of results on the initial page.
	 * @param number the number of the page, where {@code 0} is the first page.
	 */
	public static Page page(int size, int number) {
		return new Page( size, number );
	}

	/**

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass a page size greater than zero.
  2. Validate pagination parameters before building the Page.

When it happens

Trigger: A runtime precondition of the Hibernate API is violated.

Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/d3c57ebef983cba3. Report an issue: GitHub.