hibernate/hibernate-orm · error · HibernateException
increment size cannot be less than 1
Error message
increment size cannot be less than 1
What it means
Error "increment size cannot be less than 1" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledLoOptimizer.java:62
private static class GenerationState {
// last value read from db source
private Long lastSourceValue;
// the current generator value
private long value;
// the value at which we'll hit the db again
private long upperLimitValue;
}
/**
* Constructs a {@code PooledLoOptimizer}.
*
* @param returnClass The Java type of the values to be generated
* @param incrementSize The increment size.
*/
public PooledLoOptimizer(Class<?> returnClass, int incrementSize) {
super( returnClass, incrementSize );
if ( incrementSize < 1 ) {
throw new HibernateException( "increment size cannot be less than 1" );
}
OPTIMIZER_MESSAGE_LOGGER.creatingPooledLoOptimizer( incrementSize, returnClass.getName() );
}
@Override
public Serializable generate(AccessCallback callback) {
lock.lock();
try {
final var generationState = locateGenerationState( callback.getTenantIdentifier() );
if ( generationState.lastSourceValue == null
|| generationState.value >= generationState.upperLimitValue ) {
generationState.lastSourceValue = callback.getNextValue();
generationState.upperLimitValue = generationState.lastSourceValue + incrementSize;
generationState.value = generationState.lastSourceValue;
// handle cases where the initial value is less than one (hsqldb, for instance)
while ( generationState.value < 1 ) {
generationState.value++;
}View on GitHub (pinned to fad1729dce)
Solutions
- Set the generator increment size (allocationSize) to a value >= 1.
When it happens
Trigger: Thrown when an identifier optimizer is configured with an increment size smaller than 1.
Common situations: Typical situations: setting hibernate.id.optimizer or allocationSize to 0 or a negative value; a mismatched sequence increment combined with an invalid optimizer configuration.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/0f84b1a9de9796ee.
Report an issue: GitHub.