{"record":{"id":"3c3630aeb65c730b","repo":"hibernate/hibernate-orm","slug":"entity-s-does-not-specify-a-natural-id","errorCode":null,"errorMessage":"Entity %s does not specify a natural id","messagePattern":"Entity (.+?) does not specify a natural id","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java","lineNumber":383,"sourceCode":"\tEntityVersionMapping getVersionMapping();\n\n\t/**\n\t * The type of optimistic locking, if any, defined for this entity mapping\n\t */\n\tdefault OptimisticLockStyle optimisticLockStyle() {\n\t\treturn OptimisticLockStyle.NONE;\n\t}\n\n\t/**\n\t * The mapping for the natural-id of the entity, if one is defined\n\t */\n\t@Nullable NaturalIdMapping getNaturalIdMapping();\n\n\t@Nonnull\n\tdefault NaturalIdMapping requireNaturalIdMapping() {\n\t\tfinal var mapping = getNaturalIdMapping();\n\t\tif ( mapping == null ) {\n\t\t\tthrow new HibernateException( format( \"Entity %s does not specify a natural id\", getEntityName() ) );\n\t\t}\n\t\treturn mapping;\n\t}\n\n\t/**\n\t * The mapping for the row-id of the entity, if one is defined.\n\t */\n\tEntityRowIdMapping getRowIdMapping();\n\n\t/**\n\t * Mapping for soft-delete support, or {@code null} if soft-delete not defined\n\t */\n\t@Incubating\n\tdefault SoftDeleteMapping getSoftDeleteMapping() {\n\t\treturn null;\n\t}\n\n\t/**","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java#L365-L401","documentation":"Error \"Entity %s does not specify a natural id\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a natural-id load or lookup is attempted against an entity that declares no @NaturalId attributes.","commonSituations":"See trigger scenarios.","solutions":["Annotate one or more attributes of the entity with @NaturalId before using natural-id loading APIs.","Use the regular identifier lookup (find/byId) instead of natural-id access for entities without a natural id."],"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"}