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/HiLoOptimizer.java:80
public class HiLoOptimizer extends AbstractOptimizer {
private static class GenerationState {
private Long lastSourceValue;
private long upperLimit;
private long value;
}
/**
* Constructs a {@code HiLoOptimizer}
*
* @param returnClass The Java type of the values to be generated
* @param incrementSize The increment size.
*/
public HiLoOptimizer(Class<?> returnClass, int incrementSize) {
super( returnClass, incrementSize );
if ( incrementSize < 1 ) {
throw new HibernateException( "increment size cannot be less than 1" );
}
OPTIMIZER_MESSAGE_LOGGER.creatingHiLoOptimizer( incrementSize, returnClass.getName() );
}
@Override
public Serializable generate(AccessCallback callback) {
lock.lock();
try {
final GenerationState generationState = locateGenerationState( callback.getTenantIdentifier() );
if ( generationState.lastSourceValue == null ) {
// first call, so initialize ourselves. we need to read the database
// value and set up the 'bucket' boundaries
generationState.lastSourceValue = callback.getNextValue();
while ( generationState.lastSourceValue < 1 ) {
generationState.lastSourceValue = callback.getNextValue();
}
// upperLimit defines the upper end of the bucket valuesView 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/c4370abe7ced3c81.
Report an issue: GitHub.