hibernate/hibernate-orm · error · IllegalArgumentException
Expecting collection type [{javaTypeName}]
Error message
Expecting collection type [{javaTypeName}] What it means
Error "Expecting collection type [{javaTypeName}]" thrown in hibernate/hibernate-orm.
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)
Solutions
- Ensure the attribute is declared as a supported collection type (java.util.Collection, List, Set, Map, SortedSet, SortedMap) matching the mapping.
- Check that the declared Java type of the collection attribute agrees with the Hibernate mapping (bag, list, set, map).
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.