{"record":{"id":"7bb46e27fb255970","repo":"hibernate/hibernate-orm","slug":"unrecognized-value-type-java-type-valuedomain","errorCode":null,"errorMessage":"Unrecognized value type Java-type [\" + valueDomainType.getTypeName() + \"] for plural attribute value","messagePattern":"Unrecognized value type Java-type \\[\" \\+ valueDomainType\\.getTypeName\\(\\) \\+ \"\\] for plural attribute value","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmMappingModelHelper.java","lineNumber":148,"sourceCode":"\t\t\treturn new EntitySqmPathSource<>(\n\t\t\t\t\tname,\n\t\t\t\t\tpathModel,\n\t\t\t\t\tentityDomainType,\n\t\t\t\t\tjpaBindableType,\n\t\t\t\t\tisGeneric\n\t\t\t);\n\t\t}\n\t\telse if ( valueDomainType instanceof SqmMappedSuperclassDomainType<J> mappedSuperclassDomainType ) {\n\t\t\treturn new MappedSuperclassSqmPathSource<>(\n\t\t\t\t\tname,\n\t\t\t\t\tpathModel,\n\t\t\t\t\tmappedSuperclassDomainType,\n\t\t\t\t\tjpaBindableType,\n\t\t\t\t\tisGeneric\n\t\t\t);\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Unrecognized value type Java-type [\" + valueDomainType.getTypeName() + \"] for plural attribute value\"\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic static MappingModelExpressible<?> resolveMappingModelExpressible(\n\t\t\tSqmTypedNode<?> sqmNode,\n\t\t\tMappingMetamodel domainModel,\n\t\t\tFunction<NavigablePath,TableGroup> tableGroupLocator) {\n\t\tif ( sqmNode instanceof SqmPath ) {\n\t\t\treturn resolveSqmPath( (SqmPath<?>) sqmNode, domainModel, tableGroupLocator );\n\t\t}\n\n\t\tfinal SqmExpressible<?> nodeType = sqmNode.getNodeType();\n\t\tif ( nodeType instanceof BasicType ) {\n\t\t\treturn (BasicType<?>) nodeType;\n\t\t}\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmMappingModelHelper.java#L130-L166","documentation":"SqmMappingModelHelper.valuePathSource builds an SqmPathSource for the VALUE of a plural attribute by switching on the element's domain type: embedded, entity, and mapped-superclass types are handled explicitly, and anything else falls into the else branch that throws IllegalArgumentException. Reaching it means the collection's target/element type resolved to an SqmDomainType Hibernate does not recognize as a path-source-capable value type.","triggerScenarios":"An @ElementCollection (or collection-valued attribute) whose targetEntity/target class resolves to a basic or exotic user type rather than an embeddable/entity; custom collection mappings with a custom BasicType or a user-defined domain type as element; mappings that worked on one Hibernate version and hit an unhandled branch after an upgrade changed type resolution.","commonSituations":"Upgrading Hibernate (6.x/7.x) where collection element type resolution changed; @ElementCollection over an enum or custom BasicType combined with criteria value-path navigation (value() on plural paths); misdeclared targetClass on @OneToMany/@ManyToMany pointing at a non-entity class.","solutions":["Fix the mapping: @ElementCollection targets must be basic or embeddable types, @OneToMany/@ManyToMany targetEntity must be a managed entity — verify targetClass/targetEntity actually names an @Entity/@Embeddable or a supported basic type.","If you navigate the VALUE side in criteria/HQL (e.g. value(...) on a map), make sure the element is an embeddable or entity; for basic elements query the collection join directly instead of by value-path.","If the mapping follows the spec and still fails, capture the valueDomainType (name in the message) and report a Hibernate JIRA with a reproducer — the else branch indicates an unhandled mapping-model type."],"exampleFix":"// before\n@OneToMany(targetEntity = OrderStatus.class /* not an @Entity */) // element resolves to unrecognized type\nprivate List<OrderStatus> statuses;\n// criteria navigation triggers: Unrecognized value type Java-type [...]\n\n// after\n@ElementCollection\n@Enumerated(EnumType.STRING)\nprivate List<OrderStatus> statuses; // basic enum element: query via join, no entity targetClass","handlingStrategy":"try-catch","validationCode":"// Validate plural-attribute targets at startup instead of at query time\nfor (ManagedType<?> t : emf.getMetamodel().getManagedTypes()) {\n    for (Attribute<?, ?> a : t.getAttributes()) {\n        if (a.isCollection()) {\n            Type<?> elt = ((PluralAttribute<?, ?, ?>) a).getElementType();\n            // element must be basic, embeddable, or entity — flag anything you expect to be queryable by value-path\n        }\n    }\n}","typeGuard":"static boolean valuePathCapable(PluralAttribute<?, ?, ?> pa) {\n    Type.PersistenceType pt = pa.getElementType().getPersistenceType();\n    return pt == Type.PersistenceType.EMBEDDABLE || pt == Type.PersistenceType.ENTITY;\n}","tryCatchPattern":"try {\n    criteriaNavigation(); // e.g. value-path over a plural attribute\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Unrecognized value type\")) { /* fix element mapping; not a runtime-recoverable error */ throw e; }\n    throw e;\n}","preventionTips":["Declare @ElementCollection only over basic/embeddable elements and collection relations only over entity targets.","Verify targetClass/targetEntity values resolve to actual @Entity/@Embeddable classes in a startup smoke test.","After a Hibernate upgrade, run your full criteria query suite — mapping-model branches like this change between versions."],"tags":["hibernate","sqm","mapping-model","plural-attribute","element-collection"],"backgroundTag":"unrecognized-plural-attribute-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}