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/SequenceSupport.java:195
* Overloaded form of {@link #getCreateSequenceString(String)}, additionally
* taking the initial value and increment size to be applied to the sequence
* definition.
* </p>
* The default definition is to suffix {@link #getCreateSequenceString(String)}
* with the string: {@code start with initialValue increment by incrementSize}
* for the arguments {@code initialValue} and {@code incrementSize}. Dialects
* need to override this method if different key phrases are used to apply the
* allocation information.
*
* @param sequenceName The name of the sequence
* @param initialValue The initial value to apply to 'create sequence' statement
* @param incrementSize The increment value to apply to 'create sequence' statement
* @return The sequence creation command
* @throws MappingException If sequences are not supported.
*/
default 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 with " + initialValue
+ " increment by " + incrementSize;
}
/**
* The multiline script used to drop a sequence.
*
* @param sequenceName The name of the sequence
* @return The sequence drop commands
* @throws MappingException If sequences are not supported.
*/
default String[] getDropSequenceStrings(String sequenceName) throws MappingException {
return new String[]{ getDropSequenceString( sequenceName ) };
}
View on GitHub (pinned to fad1729dce)
Solutions
- Set the sequence increment size to a non-zero value in the @SequenceGenerator allocationSize / increment definition
- Remove the explicit increment=0 from the DDL or generator annotation
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/dialect/sequence/SequenceSupport.java:195 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/db11422512ce9ef0.
Report an issue: GitHub.