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/LegacyHiLoAlgorithmOptimizer.java:51
private static class GenerationState {
private long maxLo;
private long lo;
private long hi;
private Long lastSourceValue;
private long value;
}
/**
* Constructs a {@code LegacyHiLoAlgorithmOptimizer}
*
* @param returnClass The Java type of the values to be generated
* @param incrementSize The increment size.
*/
public LegacyHiLoAlgorithmOptimizer(Class<?> returnClass, int incrementSize) {
super( returnClass, incrementSize );
if ( incrementSize < 1 ) {
throw new HibernateException( "increment size cannot be less than 1" );
}
OPTIMIZER_MESSAGE_LOGGER.creatingLegacyHiLoOptimizer( incrementSize, returnClass.getName() );
initialMaxLo = incrementSize;
}
@Override
public Serializable generate(AccessCallback callback) {
lock.lock();
try {
final var generationState = locateGenerationState( callback.getTenantIdentifier() );
if ( generationState.lo > generationState.maxLo ) {
generationState.lastSourceValue = callback.getNextValue();
generationState.lo = generationState.lastSourceValue == 0 ? 1 : 0;
generationState.hi = generationState.lastSourceValue * ( generationState.maxLo + 1 );
}
generationState.value = generationState.hi + generationState.lo++;
return makeIntegralValue( generationState.value, returnClass );
}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/053ecffcb4899127.
Report an issue: GitHub.