{"record":{"id":"eedcdb675292ab75","repo":"hibernate/hibernate-orm","slug":"not-implemented-yet","errorCode":null,"errorMessage":"Not implemented yet","messagePattern":"Not implemented yet","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/EntityTableMappingImpl.java","lineNumber":397,"sourceCode":"\t\t\t\t\t!sqlSelection.isVirtual()\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic static class CompositeKeyMapping extends AbstractKeyMapping {\n\t\tpublic CompositeKeyMapping(List<KeyColumn> keyColumns, EmbeddableValuedModelPart identifierPart) {\n\t\t\tsuper( keyColumns, identifierPart );\n\t\t}\n\n\t\t@Override\n\t\tpublic <K> DomainResult<K> createDomainResult(\n\t\t\t\tNavigablePath navigablePath,\n\t\t\t\tTableReference tableReference,\n\t\t\t\tString resultVariable,\n\t\t\t\tDomainResultCreationState creationState) {\n\t\t\t// this will be challenging if the embeddable defines to-ones.\n\t\t\t// just error for now.\n\t\t\tthrow new UnsupportedOperationException( \"Not implemented yet\" );\n\t\t}\n\t}\n\n\tpublic static class KeyColumn extends SelectableMappingImpl implements TableDetails.KeyColumn {\n\n\t\tpublic KeyColumn(String tableName, SelectableMapping originalMapping) {\n\t\t\tsuper(\n\t\t\t\t\ttableName,\n\t\t\t\t\toriginalMapping.getSelectionExpression(),\n\t\t\t\t\tnull, // Leads to construction of a fresh path based on selection expression\n\t\t\t\t\toriginalMapping.getCustomReadExpression(),\n\t\t\t\t\toriginalMapping.getCustomWriteExpression(),\n\t\t\t\t\toriginalMapping.getLength(),\n\t\t\t\t\toriginalMapping.getPrecision(),\n\t\t\t\t\toriginalMapping.getScale(),\n\t\t\t\t\toriginalMapping.getTemporalPrecision(),\n\t\t\t\t\toriginalMapping.isLob(),\n\t\t\t\t\toriginalMapping.isNullable(),","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/EntityTableMappingImpl.java#L379-L415","documentation":"EntityTableMappingImpl.CompositeKeyMapping.createDomainResult builds a DomainResult for an @EmbeddedId identifier. The source comment states the deliberate limitation: 'this will be challenging if the embeddable defines to-ones. just error for now.' UnsupportedOperationException is therefore thrown whenever a query path needs the composite id as a domain result and the embeddable contains to-one associations.","triggerScenarios":"HQL/Criteria selecting the composite id as a whole navigable (e.g. cb.construct(..., root.get(\"id\")), selection of the id path, id()-style references) for an entity whose @EmbeddedId embeddable declares @ManyToOne/@OneToOne fields; native/criteria result construction that materializes the id navigable.","commonSituations":"The classic JPA pattern of putting @ManyToOne inside the @EmbeddedId (instead of derived identity with @MapsId) and later selecting or projecting the id as a whole; upgrades that route existing queries through this code path.","solutions":["Refactor to JPA derived identity: put @ManyToOne + @MapsId on the entity and keep only plain columns in the embeddable - no associations inside @EmbeddedId","Select the id's components individually (root.get(\"id\").get(\"part\")) instead of the composite as a whole","If refactoring is too invasive, load by id (EntityManager.find) instead of projecting the id navigable","Check the Hibernate version's issue tracker for CompositeKeyMapping.createDomainResult support before relying on it"],"exampleFix":"// before: association inside @EmbeddedId -> createDomainResult throws\n@Embeddable\npublic class OrderLineId implements Serializable {\n    @ManyToOne Order order;   // to-one inside embeddable\n    int lineNo;\n}\n\n@Entity\npublic class OrderLine {\n    @EmbeddedId OrderLineId id;\n}\n\n// after: derived identity with @MapsId\n@Embeddable\npublic class OrderLineId implements Serializable {\n    Long orderId;             // plain column\n    int lineNo;\n}\n\n@Entity\npublic class OrderLine {\n    @EmbeddedId OrderLineId id;\n    @ManyToOne(fetch = LAZY)\n    @MapsId(\"orderId\")\n    Order order;\n}","handlingStrategy":"type-guard","validationCode":"// reject risky @EmbeddedId shapes at bootstrap, not at query time\nstatic boolean embeddableHasAssociations(Class<?> idClass) {\n    for (Field f : idClass.getDeclaredFields()) {\n        if (f.isAnnotationPresent(ManyToOne.class) || f.isAnnotationPresent(OneToOne.class)) return true;\n    }\n    return false;\n}","typeGuard":"static boolean isSafeEmbeddedId(Class<?> idClass) {\n    for (Field f : idClass.getDeclaredFields()) {\n        if (f.isAnnotationPresent(ManyToOne.class) || f.isAnnotationPresent(OneToOne.class)) {\n            return false; // composite-key domain results unsupported for this shape\n        }\n    }\n    return true;\n}","tryCatchPattern":"try { results = criteriaQuery.select(root.get(\"id\")).getResultList(); } catch (UnsupportedOperationException e) { /* select id components individually instead of the composite */ }","preventionTips":["Prefer @ManyToOne + @MapsId derived identity over associations inside @EmbeddedId","Never project the composite id as a whole navigable; select its parts","Add a mapping test that flags embeddables containing to-one fields"],"tags":["hibernate","orm","embedded-id","composite-key","not-implemented","criteria"],"backgroundTag":"embedded-id-association-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}