hibernate/hibernate-orm · error · MappingException

Unable to create the sequence [{}]: the increment size must

Error message

Unable to create the sequence [{}]: the increment size must not be 0

What it means

Error "Unable to create the sequence [{}]: the increment size must not be 0" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/sequence/SpannerPostgreSQLSequenceSupport.java:27

public class SpannerPostgreSQLSequenceSupport extends PostgreSQLSequenceSupport {

	private final SpannerPostgreSQLDialect dialect;

	public SpannerPostgreSQLSequenceSupport(SpannerPostgreSQLDialect dialect) {
		super();
		this.dialect = dialect;
	}

	@Override
	public boolean supportsPooledSequences() {
		return false;
	}

	@Override
	public String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException {
		if ( incrementSize == 0 ) {
			throw new MappingException( "Unable to create the sequence [" + sequenceName + "]: the increment size must not be 0" );
		}
		return getCreateSequenceString( sequenceName )
			+ startingValue( initialValue, incrementSize )
			+ " start counter with " + initialValue;
	}

	@Override
	public String getRestartSequenceString(String sequenceName, long startWith) {
		return "alter sequence " + sequenceName + " restart counter with " + startWith;
	}

	@Override
	public String getSelectSequenceNextValString(String sequenceName) {
		var nextValString = super.getSelectSequenceNextValString( sequenceName );
		if (dialect.useIntegerForPrimaryKey()) {
			nextValString = "spanner.bit_reverse(" + nextValString + ", true)";
		}
		return nextValString;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a non-zero increment size for the sequence; Cloud Spanner requires a valid increment
  2. Correct the @SequenceGenerator allocationSize so it is not 0

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/dialect/sequence/SpannerPostgreSQLSequenceSupport.java:27 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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