hibernate/hibernate-orm · error · UnsupportedMappingException

Entity may not define both @SoftDelete and @SQLDelete

Error message

Entity may not define both @SoftDelete and @SQLDelete

What it means

Error "Entity may not define both @SoftDelete and @SQLDelete" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java:5606

	}

	private void prepareMappingModel(MappingModelCreationProcess creationProcess, PersistentClass bootEntityDescriptor) {
		final var instantiator = getRepresentationStrategy().getInstantiator();
		final Supplier<?> instantiate = instantiator.canBeInstantiated() ? instantiator::instantiate : null;
		identifierMapping =
				creationProcess.processSubPart( EntityIdentifierMapping.ID_ROLE_NAME,
						(role, process) -> generateIdentifierMapping( instantiate, bootEntityDescriptor, process ) );
		versionMapping = generateVersionMapping( instantiate, bootEntityDescriptor, creationProcess );
		rowIdMapping = rowIdName == null ? null
				: creationProcess.processSubPart( rowIdName,
						(role, process) -> new EntityRowIdMappingImpl( rowIdName, getTableName(), this ) );
		discriminatorMapping = generateDiscriminatorMapping( bootEntityDescriptor );
		final var rootClass = bootEntityDescriptor.getRootClass();
		auxiliaryMapping = rootClass == bootEntityDescriptor ?
				stateManagement.createAuxiliaryMapping( this, rootClass, creationProcess ) :
				superMappingType.getAuxiliaryMapping();
		if ( auxiliaryMapping instanceof SoftDeleteMapping && rootClass.getCustomSQLDelete() != null ) {
			throw new UnsupportedMappingException( "Entity may not define both @SoftDelete and @SQLDelete" );
		}
	}

	private void initializeNaturalIdMapping
			(MappingModelCreationProcess creationProcess, PersistentClass bootEntityDescriptor) {
		if ( superMappingType != null ) {
			naturalIdMapping = superMappingType.getNaturalIdMapping();
		}
		else if ( bootEntityDescriptor.hasNaturalId() ) {
			naturalIdMapping = generateNaturalIdMapping( creationProcess, bootEntityDescriptor );
		}
		else {
			naturalIdMapping = null;
		}
	}

	protected NaturalIdMapping generateNaturalIdMapping(
			MappingModelCreationProcess creationProcess,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use either @SoftDelete or @SQLDelete on the entity, not both.

When it happens

Trigger: Thrown at bootstrap when an entity is annotated with both @SoftDelete and @SQLDelete; only one delete strategy is allowed.

Common situations: See trigger scenarios.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/d0e809a4ad2183eb. Report an issue: GitHub.