{"record":{"id":"d0a00b3e5cadac10","repo":"hibernate/hibernate-orm","slug":"only-support-for-basic-valued-entity-valued-and-e","errorCode":null,"errorMessage":"Only support for basic-valued, entity-valued and embedded model-parts have been implemented : \" + propertyPath + \" [\" + subPart + \"]","messagePattern":"Only support for basic-valued, entity-valued and embedded model-parts have been implemented : \" \\+ propertyPath \\+ \" \\[\" \\+ subPart \\+ \"\\]","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/query/SqlResultSetMappingDescriptor.java","lineNumber":489,"sourceCode":"\t\t\t\t\t: parentNavigablePath.append( rootPropertyPathPart );\n\t\t}\n\n\t\t@Nonnull\n\t\tprivate FetchMemento getFetchMemento(NavigablePath navigablePath, ModelPart subPart) {\n\t\t\tfinal var basicPart = subPart.asBasicValuedModelPart();\n\t\t\tif ( basicPart != null ) {\n\t\t\t\tassert columnNames.size() == 1;\n\t\t\t\treturn new FetchMementoBasicStandard( navigablePath, basicPart, columnNames.get( 0 ) );\n\t\t\t}\n\t\t\telse if ( subPart instanceof EntityValuedFetchable entityValuedFetchable ) {\n\t\t\t\treturn new FetchMementoEntityStandard( navigablePath, entityValuedFetchable, columnNames );\n\t\t\t}\n\t\t\telse if( subPart instanceof EmbeddedAttributeMapping embeddedAttributeMapping ){\n\t\t\t\treturn getFetchMemento( navigablePath,\n\t\t\t\t\t\tembeddedAttributeMapping.findSubPart( unroot( propertyPath ), null ) );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\t\t\"Only support for basic-valued, entity-valued and embedded model-parts have been implemented : \" + propertyPath\n\t\t\t\t\t\t+ \" [\" + subPart + \"]\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":471,"sourceCodeEnd":497,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/query/SqlResultSetMappingDescriptor.java#L471-L497","documentation":"Hibernate resolves every property path in a @SqlResultSetMapping (@EntityResult + @FieldResult/@ColumnResult) against the domain model when it builds the mapping's fetch mementos. Only three model-part shapes are supported: basic-valued (exactly one column), entity-valued fetchables (FK columns), and embedded attributes (which it recurses into). If the path resolves to anything else - a plural/collection attribute, an @Any mapping, an array - this UnsupportedOperationException is thrown, naming the offending propertyPath and subPart.","triggerScenarios":"A native SQL query with @SqlResultSetMapping where a @FieldResult points to a @OneToMany/@ManyToMany/@ElementCollection attribute or another non-basic/non-entity/non-embedded model part; also nested paths through a collection. Thrown during bootstrap while Hibernate compiles the named native query mapping.","commonSituations":"Trying to map joined collection columns into an entity result; porting a JPQL JOIN FETCH query to a native query with field results; upgrading Hibernate versions where mapping resolution got stricter; pointing a field result at an association whose resolved part type is unsupported.","solutions":["Remove the @FieldResult entry that targets the collection/plural attribute and load collections via a separate query or JOIN FETCH in JPQL","If the attribute is embedded, map the embedding attribute itself and let Hibernate recurse into its sub-parts","For association columns, map them as a separate @EntityResult or as @ColumnResult scalars instead of a field result on a collection","Return scalar columns and use @ConstructorResult with a DTO instead of mapping collections into the entity result"],"exampleFix":"// before\n@SqlResultSetMapping(\n  name = \"OrderMapping\",\n  entities = @EntityResult(\n    entityClass = Order.class,\n    fields = {\n      @FieldResult(name = \"id\", column = \"order_id\"),\n      @FieldResult(name = \"items\", column = \"item_id\") // 'items' is @OneToMany -> unsupported\n    }))\n\n// after\n@SqlResultSetMapping(\n  name = \"OrderMapping\",\n  entities = @EntityResult(\n    entityClass = Order.class,\n    fields = @FieldResult(name = \"id\", column = \"order_id\")))\n// fetch items separately: select o from Order o join fetch o.items","handlingStrategy":"validation","validationCode":"// Before building the EMF, verify every @FieldResult path targets a supported attribute kind\nMetamodel mm = factory.getMetamodel(); // or use reflection over mapping annotations at deploy time\nSet<String> plural = ((SingularAttribute) null) == null ? null : null; // sketch:\nSet<String> pluralNames = entityManagerFactory.getMetamodel()\n    .entity(Order.class).getPluralAttributes().stream()\n    .map(Attribute::getName).collect(Collectors.toSet());\nfor (String path : fieldResultPathsForOrder) {\n    if (pluralNames.contains(root(path))) {\n        throw new IllegalArgumentException(\"FieldResult targets plural attribute: \" + path);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    emf = Persistence.createEntityManagerFactory(\"pu\");\n} catch (PersistenceException e) {\n    if (e.getCause() instanceof UnsupportedOperationException uoe\n            && uoe.getMessage().contains(\"model-parts\")) {\n        // log the propertyPath from the message and fix the @SqlResultSetMapping\n    }\n    throw e;\n}","preventionTips":["Keep @FieldResult paths on basic, embedded, or FK attributes only - never collections","Add a startup smoke test that builds all named native queries at deploy time, not on first query","Prefer JOIN FETCH JPQL over native SQL mappings for collection initialization"],"tags":["hibernate","native-query","sql-result-set-mapping","orm","mapping","boot"],"backgroundTag":"result-set-mapping-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}