{"record":{"id":"d0e809a4ad2183eb","repo":"hibernate/hibernate-orm","slug":"entity-may-not-define-both-softdelete-and-sqldel","errorCode":null,"errorMessage":"Entity may not define both @SoftDelete and @SQLDelete","messagePattern":"Entity may not define both @SoftDelete and @SQLDelete","errorType":"exception","errorClass":"UnsupportedMappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java","lineNumber":5606,"sourceCode":"\t}\n\n\tprivate void prepareMappingModel(MappingModelCreationProcess creationProcess, PersistentClass bootEntityDescriptor) {\n\t\tfinal var instantiator = getRepresentationStrategy().getInstantiator();\n\t\tfinal Supplier<?> instantiate = instantiator.canBeInstantiated() ? instantiator::instantiate : null;\n\t\tidentifierMapping =\n\t\t\t\tcreationProcess.processSubPart( EntityIdentifierMapping.ID_ROLE_NAME,\n\t\t\t\t\t\t(role, process) -> generateIdentifierMapping( instantiate, bootEntityDescriptor, process ) );\n\t\tversionMapping = generateVersionMapping( instantiate, bootEntityDescriptor, creationProcess );\n\t\trowIdMapping = rowIdName == null ? null\n\t\t\t\t: creationProcess.processSubPart( rowIdName,\n\t\t\t\t\t\t(role, process) -> new EntityRowIdMappingImpl( rowIdName, getTableName(), this ) );\n\t\tdiscriminatorMapping = generateDiscriminatorMapping( bootEntityDescriptor );\n\t\tfinal var rootClass = bootEntityDescriptor.getRootClass();\n\t\tauxiliaryMapping = rootClass == bootEntityDescriptor ?\n\t\t\t\tstateManagement.createAuxiliaryMapping( this, rootClass, creationProcess ) :\n\t\t\t\tsuperMappingType.getAuxiliaryMapping();\n\t\tif ( auxiliaryMapping instanceof SoftDeleteMapping && rootClass.getCustomSQLDelete() != null ) {\n\t\t\tthrow new UnsupportedMappingException( \"Entity may not define both @SoftDelete and @SQLDelete\" );\n\t\t}\n\t}\n\n\tprivate void initializeNaturalIdMapping\n\t\t\t(MappingModelCreationProcess creationProcess, PersistentClass bootEntityDescriptor) {\n\t\tif ( superMappingType != null ) {\n\t\t\tnaturalIdMapping = superMappingType.getNaturalIdMapping();\n\t\t}\n\t\telse if ( bootEntityDescriptor.hasNaturalId() ) {\n\t\t\tnaturalIdMapping = generateNaturalIdMapping( creationProcess, bootEntityDescriptor );\n\t\t}\n\t\telse {\n\t\t\tnaturalIdMapping = null;\n\t\t}\n\t}\n\n\tprotected NaturalIdMapping generateNaturalIdMapping(\n\t\t\tMappingModelCreationProcess creationProcess,","sourceCodeStart":5588,"sourceCodeEnd":5624,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java#L5588-L5624","documentation":"Error \"Entity may not define both @SoftDelete and @SQLDelete\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at bootstrap when an entity is annotated with both @SoftDelete and @SQLDelete; only one delete strategy is allowed.","commonSituations":"See trigger scenarios.","solutions":["Use either @SoftDelete or @SQLDelete on the entity, not both."],"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"}