{"record":{"id":"045521b88432e243","repo":"hibernate/hibernate-orm","slug":"property-getpath-propertyholder-inferreddat","errorCode":null,"errorMessage":"Property '\" + getPath( propertyHolder, inferredData ) + \"' belongs to an '@IdClass' and may not be annotated '@Id' or '@EmbeddedId'","messagePattern":"Property '\" \\+ getPath\\( propertyHolder, inferredData \\) \\+ \"' belongs to an '@IdClass' and may not be annotated '@Id' or '@EmbeddedId'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java","lineNumber":1268,"sourceCode":"\t\t\t\t\tmemberDetails,\n\t\t\t\t\tactualColumns\n\t\t\t);\n\t\t}\n\t\treturn this;\n\t}\n\n\tprivate void handleGenerators(\n\t\t\tPropertyHolder propertyHolder,\n\t\t\tPropertyData inferredData,\n\t\t\tboolean isIdentifierMapper,\n\t\t\tboolean isOverridden,\n\t\t\tPropertyData overridingProperty) {\n\t\tif ( isOverridden ) {\n\t\t\thandleGeneratorsForOverriddenId( propertyHolder, overridingProperty );\n\t\t}\n\t\telse if ( isId() ) {\n\t\t\tif ( isIdentifierMapper ) {\n\t\t\t\tthrow new AnnotationException( \"Property '\" + getPath( propertyHolder, inferredData )\n\t\t\t\t\t\t+ \"' belongs to an '@IdClass' and may not be annotated '@Id' or '@EmbeddedId'\" );\n\t\t\t}\n\t\t\t//components and regular basic types create SimpleValue objects\n\t\t\tcreateIdGeneratorsFromGeneratorAnnotations(\n\t\t\t\t\tpropertyHolder,\n\t\t\t\t\tinferredData,\n\t\t\t\t\t(SimpleValue) getValue(),\n\t\t\t\t\tbuildingContext\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate void aggregateBinder(\n\t\t\tPropertyHolder propertyHolder,\n\t\t\tPropertyData inferredData,\n\t\t\tEntityBinder entityBinder,\n\t\t\tboolean isIdentifierMapper,\n\t\t\tboolean isComponentEmbedded,","sourceCodeStart":1250,"sourceCodeEnd":1286,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java#L1250-L1286","documentation":"Inside an @IdClass property mapper, none of the mirrored properties may themselves be annotated @Id or @EmbeddedId — the entity already declares the composite id via @Id fields plus @IdClass. PropertyBinder's generator handling throws AnnotationException when it finds an id annotation while binding in identifier-mapper mode.","triggerScenarios":"An entity with @IdClass(OrderLineId.class) where the entity fields carry @Id AND the id-class side (or overridden/merged property data reaching the mapper) is re-annotated @Id/@EmbeddedId; typically double annotation after merging classes or misusing an @EmbeddedId field together with @IdClass.","commonSituations":"Mixing the two composite-id styles (@IdClass and @EmbeddedId) on one entity; copy-paste between an @EmbeddedId entity and an @IdClass entity; refactors where the id-class fields were copied back onto the entity with their annotations.","solutions":["Pick one composite-id style: either @IdClass with multiple @Id fields on the entity, or a single @EmbeddedId field — never both.","Remove the offending @Id/@EmbeddedId annotation that reached the identifier mapper (usually the duplicated one).","Verify the id class contains only plain fields matching the entity's @Id fields in name and type."],"exampleFix":"// before: both composite-id styles mixed\n@Entity\n@IdClass(OrderLineId.class)\npublic class OrderLine {\n    @Id private Long order;\n    @Id private Long line;\n    @EmbeddedId         // rejected: property already in the @IdClass mapper\n    private OrderLineId id;\n}\n\n// after: single style\n@Entity\n@IdClass(OrderLineId.class)\npublic class OrderLine {\n    @Id private Long order;\n    @Id private Long line;\n}","handlingStrategy":"validation","validationCode":"// Don't mix @IdClass and @EmbeddedId on one entity\nfor (Class<?> entity : annotatedClasses) {\n    boolean hasIdClass = entity.isAnnotationPresent(IdClass.class);\n    boolean hasEmbeddedId = Arrays.stream(entity.getDeclaredFields())\n            .anyMatch(f -> f.isAnnotationPresent(EmbeddedId.class));\n    if (hasIdClass && hasEmbeddedId) {\n        throw new IllegalStateException(entity.getName() + \" mixes @IdClass and @EmbeddedId\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    SessionFactory sf = cfg.buildSessionFactory();\n} catch (AnnotationException e) {\n    throw new IllegalStateException(\"Composite id style conflict: \" + e.getMessage(), e);\n}","preventionTips":["Choose one composite-id style per entity and per codebase convention","When converting between @EmbeddedId and @IdClass, remove all traces of the old style"],"tags":["hibernate","jpa","idclass","embedded-id","composite-key","annotation-conflict","bootstrap"],"backgroundTag":"idclass-mapping-error","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}