hibernate/hibernate-orm · error · MappingException

The increment size of the [%s] sequence is set to [%d] in th

Error message

The increment size of the [%s] sequence is set to [%d] in the entity mapping but the mapped database sequence increment size is [%d]

What it means

Error "The increment size of the [%s] sequence is set to [%d] in the entity mapping but the mapped database sequence increment size is [%d]" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java:311

				isSchemaToBeRecreated( contributor, configurationService ) ? null
						: getSequenceIncrementValue( jdbcEnvironment, databaseSequenceName );
		if ( databaseIncrementValue != null && databaseIncrementValue.intValue() != incrementSize ) {
			final int dbIncrementValue = databaseIncrementValue.intValue();
			return switch ( sequenceMismatchStrategy ) {
				case NONE -> incrementSize;
				case FIX -> {
					// log at TRACE level
					SEQUENCE_GENERATOR_LOGGER.sequenceIncrementSizeMismatchFixed(
							databaseSequenceName, incrementSize, dbIncrementValue );
					yield dbIncrementValue;
				}
				case LOG -> {
					// log at WARN level
					SEQUENCE_GENERATOR_LOGGER.sequenceIncrementSizeMismatch(
							databaseSequenceName, incrementSize, dbIncrementValue );
					yield incrementSize;
				}
				case EXCEPTION -> throw new MappingException(
						String.format(
								"The increment size of the [%s] sequence is set to [%d] in the entity mapping "
									+ "but the mapped database sequence increment size is [%d]",
								databaseSequenceName, incrementSize, dbIncrementValue
						)
				);
			};
		}
		else {
			return incrementSize;
		}
	}

	private boolean isSchemaToBeRecreated(String contributor, ConfigurationService configurationService) {
		final var actions =
				ActionGrouping.interpret( singleton( contributor ),
						configurationService.getSettings() );
		// We know this will only contain at most 1 action

View on GitHub (pinned to fad1729dce)

Solutions

  1. Align the mapping's allocationSize with the database sequence's INCREMENT BY value.
  2. Or set hibernate.id.sequence.increment_size_mismatch_strategy=FIX to auto-correct.
  3. Or recreate the database sequence with the matching increment.

When it happens

Trigger: Thrown when the entity mapping's sequence increment size does not match the database sequence's actual increment.

Common situations: Typical situations: DBA changed the sequence increment; allocationSize in the mapping differs from the DDL; mismatch strategy set to EXCEPTION.


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