hibernate/hibernate-orm · error · IllegalArgumentException

Expecting collection type

Error message

Expecting collection type [{javaTypeName}]

What it means

Metamodel-building guard in determineCollectionType: the mapped plural attribute's Java type is neither a Map/Set/List/Collection nor an array, so it cannot be classified into any supported CollectionClassification.

Solutions

  1. Ensure the attribute is declared as a supported collection type (java.util.Collection, List, Set, Map, SortedSet, SortedMap) matching the mapping.
  2. Check that the declared Java type of the collection attribute agrees with the Hibernate mapping (bag, list, set, map).
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown when a plural attribute's declared Java type does not match the collection classification implied by its mapping annotations (e.g. mapping a Set-typed attribute as a List).

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/internal/PluralAttributeMetadataImpl.java:202

			if ( collection.isSorted() ) {
				return SORTED_MAP;
			}
			else if ( collection.hasOrder() ) {
				return ORDERED_MAP;
			}
			else {
				return MAP;
			}
		}
		else if ( java.util.Collection.class.isAssignableFrom( javaType ) ) {
			return collection.isIdentified() ? ID_BAG : BAG;

		}
		else if ( javaType.isArray() ) {
			return CollectionClassification.ARRAY;
		}
		else {
			throw new IllegalArgumentException( "Expecting collection type [" + javaType.getName() + "]" );
		}
	}

	@Override
	public ValueContext getElementValueContext() {
		return elementValueContext;
	}

	@Override
	public CollectionClassification getCollectionClassification() {
		return collectionClassification;
	}

	@Override
	public ValueContext getMapKeyValueContext() {
		return keyValueContext;
	}
}

View on GitHub (pinned to fad1729dce)