{"record":{"id":"708d5f44506b5d31","repo":"hibernate/hibernate-orm","slug":"entity-entity-has-no-identifier-every-enti","errorCode":null,"errorMessage":"Entity '${entity}' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)","messagePattern":"Entity '(.+?)' has no identifier \\(every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java","lineNumber":248,"sourceCode":"\t\t\tgetMappedSuperclassesTillNextEntityOrdered();\n\n\t\t\tfinal var defaultAccessType = determineDefaultAccessType();\n\n\t\t\tif ( classDetails.hasDirectAnnotationUsage( Access.class ) ) {\n\t\t\t\taccessType = getAccessStrategy( classDetails.getDirectAnnotationUsage( Access.class ).value() );\n\t\t\t}\n\t\t\telse {\n\t\t\t\taccessType = defaultAccessType;\n\t\t\t}\n\n\t\t\tfinal ArrayList<PropertyData> elements = new ArrayList<>();\n\t\t\tint idPropertyCount = 0;\n\t\t\tfor ( var classToProcessForMappedSuperclass : classesToProcessForMappedSuperclass ) {\n\t\t\t\tfinal var container = new PropertyContainer( classToProcessForMappedSuperclass, classDetails, defaultAccessType );\n\t\t\t\tidPropertyCount = addElementsOfClass( elements, container, buildingContext, idPropertyCount );\n\t\t\t}\n\t\t\tif ( idPropertyCount == 0 && !inheritanceState.hasParents() ) {\n\t\t\t\tthrow new AnnotationException( \"Entity '\" + classDetails.getName() + \"' has no identifier\"\n\t\t\t\t\t\t+ \" (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)\" );\n\t\t\t}\n\t\t\telements.trimToSize();\n\t\t\telementsToProcess = new ElementsToProcess( elements, idPropertyCount );\n\t\t}\n\t\treturn elementsToProcess;\n\t}\n\n\tprivate AccessType determineDefaultAccessType() {\n\n\t\t// do not check for `@Access` to determine the default access type of the hierarchy\n\n\t\tfinal var idAccessType = determineAccessTypeFromId( classDetails );\n\t\tif ( idAccessType != null ) {\n\t\t\treturn idAccessType;\n\t\t}\n\n\t\t// next consider the current class","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java#L230-L266","documentation":"Error \"Entity '${entity}' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A composite identifier mapping (@IdClass/@EmbeddedId/@MapsId) does not match the entity's persistent properties.","commonSituations":"Composite primary keys where the id class properties, their types, or @MapsId values drift out of sync with the entity, or an embeddable with inheritance is reused as an id.","solutions":["Declare an @Id or @EmbeddedId property on the entity or one of its superclasses."],"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"}