hibernate/hibernate-orm · error · IllegalArgumentException

Collection must be not null

Error message

Collection must be not null

What it means

Error "Collection must be not null" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/FilterImpl.java:137

			parameters = new TreeMap<>();
		}
		parameters.put( name, argument );
		validated = false;
		return this;
	}

	/**
	 * Set the named parameter's value list for this filter.  Used
	 * in conjunction with IN-style filter criteria.
	 *
	 * @param name   The parameter's name.
	 * @param values The values to be expanded into an SQL IN list.
	 * @return This FilterImpl instance (for method chaining).
	 */
	public Filter setParameterList(String name, Collection<?> values) throws HibernateException  {
		// Make sure this is a defined parameter and check the incoming value type
		if ( values == null ) {
			throw new IllegalArgumentException( "Collection must be not null" );
		}
		final var type = definition.getParameterJdbcMapping( name );
		if ( type == null ) {
			throw new HibernateException( "Undefined filter parameter '" + name + "'" );
		}
		if ( !values.isEmpty() ) {
			final Object element = values.iterator().next();
			if ( !type.getJavaTypeDescriptor().isInstance( element ) ) {
				throw new IllegalArgumentException( "Argument assigned to filter parameter '" + name
						+ "' is not of type '" + type.getJavaTypeDescriptor().getTypeName() + "'" );
			}
		}
		if ( parameters == null ) {
			parameters = new TreeMap<>();
		}
		parameters.put( name, values );
		validated = false;
		return this;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass a non-null collection to the filter's collection parameter.

When it happens

Trigger: Thrown when a caller passes a null Collection to the API guarded in FilterImpl.java:137.

Common situations: Typical situations: calling the method with an uninitialized variable; a lookup that returned null being passed straight through; missing null-checks in application code before invoking Hibernate.


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