hibernate/hibernate-orm · error · MappingException

Identity generation requires exactly one column

Error message

Identity generation requires exactly one column

What it means

Error "Identity generation requires exactly one column" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/id/GenericGeneratorGeneration.java:117

	private static Properties collectParameters(
			GenericGenerator annotation,
			GeneratorCreationContext context) {
		final Map<String,Object> configuration = new HashMap<>();
		for ( var parameter : annotation.parameters() ) {
			configuration.put( parameter.name(), parameter.value() );
		}
		return GeneratorParameters.collectParameters(
				context.getValue(),
				context.getDatabase().getDialect(),
				context.getRootClass(),
				configuration,
				context.getServiceRegistry().requireService( ConfigurationService.class )
		);
	}

	private static void setColumnToIdentity(Value value) {
		if ( value.getColumnSpan() != 1 ) {
			throw new MappingException( "Identity generation requires exactly one column" );
		}
		else {
			value.getColumns().get( 0 ).setIdentity( true );
		}
	}

	@Override
	public boolean generatedOnExecution() {
		return delegate.generatedOnExecution();
	}

	@Override
	public boolean generatedOnExecution(Object entity, SharedSessionContractImplementor session) {
		return delegate.generatedOnExecution( entity, session );
	}

	@Override
	public boolean generatedBeforeExecution(Object entity, SharedSessionContractImplementor session) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Map the identity column as a single (non-composite) column; identity generation supports exactly one column.

When it happens

Trigger: Thrown when a generation strategy that supports a single column is mapped to multiple (or no) columns.

Common situations: Typical situations: identity/timestamp generation mapped on a composite attribute; wrong @Column mapping for the generated property.


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