{"record":{"id":"bd32a3540d10b20c","repo":"hibernate/hibernate-orm","slug":"expecting-collection-type-javatypename","errorCode":null,"errorMessage":"Expecting collection type [{javaTypeName}]","messagePattern":"Expecting collection type \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/internal/PluralAttributeMetadataImpl.java","lineNumber":202,"sourceCode":"\t\t\tif ( collection.isSorted() ) {\n\t\t\t\treturn SORTED_MAP;\n\t\t\t}\n\t\t\telse if ( collection.hasOrder() ) {\n\t\t\t\treturn ORDERED_MAP;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn MAP;\n\t\t\t}\n\t\t}\n\t\telse if ( java.util.Collection.class.isAssignableFrom( javaType ) ) {\n\t\t\treturn collection.isIdentified() ? ID_BAG : BAG;\n\n\t\t}\n\t\telse if ( javaType.isArray() ) {\n\t\t\treturn CollectionClassification.ARRAY;\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException( \"Expecting collection type [\" + javaType.getName() + \"]\" );\n\t\t}\n\t}\n\n\t@Override\n\tpublic ValueContext getElementValueContext() {\n\t\treturn elementValueContext;\n\t}\n\n\t@Override\n\tpublic CollectionClassification getCollectionClassification() {\n\t\treturn collectionClassification;\n\t}\n\n\t@Override\n\tpublic ValueContext getMapKeyValueContext() {\n\t\treturn keyValueContext;\n\t}\n}","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/internal/PluralAttributeMetadataImpl.java#L184-L220","documentation":"Error \"Expecting collection type [{javaTypeName}]\" thrown in hibernate/hibernate-orm.","triggerScenarios":"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).","commonSituations":"See trigger scenarios.","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)."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}