hibernate/hibernate-orm · error · IllegalArgumentException

The predicate list cannot be null

Error message

The predicate list cannot be null

What it means

Error "The predicate list cannot be null" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/SqmQuerySpec.java:409

			throw new IllegalArgumentException( "The predicate array cannot be null" );
		}
		else if ( restrictions.length == 0 ) {
			setWhereClause( null );
		}
		else {
			final var whereClause = resetWhereClause();
			for ( var restriction : restrictions ) {
				whereClause.applyPredicate( (SqmPredicate) restriction );
			}
		}
		return this;
	}

	@Nonnull
	@Override
	public SqmQuerySpec<T> setRestriction(List<Predicate> restrictions) {
		if ( restrictions == null ) {
			throw new IllegalArgumentException( "The predicate list cannot be null" );
		}
		else if ( restrictions.isEmpty() ) {
			setWhereClause( null );
		}
		else {
			final var whereClause = resetWhereClause();
			for ( var restriction : restrictions ) {
				whereClause.applyPredicate( (SqmPredicate) restriction );
			}
		}
		return this;
	}

	private SqmWhereClause resetWhereClause() {
		final var whereClause = getWhereClause();
		if ( whereClause == null ) {
			final var newWhereClause = new SqmWhereClause( nodeBuilder() );
			setWhereClause( newWhereClause );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass a non-null list of predicates; use Collections.emptyList() if there are no restrictions, or skip the call.
  2. Add a null check at the call site and only invoke the method when the list is populated.

When it happens

Trigger: A restriction method is invoked with a null List<Predicate> on a criteria query specification.

Common situations: Passing a null predicate list to where()/having(); initialize the list before use.


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