{"record":{"id":"c4370abe7ced3c81","repo":"hibernate/hibernate-orm","slug":"increment-size-cannot-be-less-than-1","errorCode":null,"errorMessage":"increment size cannot be less than 1","messagePattern":"increment size cannot be less than 1","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/id/enhanced/HiLoOptimizer.java","lineNumber":80,"sourceCode":"public class HiLoOptimizer extends AbstractOptimizer {\n\n\tprivate static class GenerationState {\n\t\tprivate Long lastSourceValue;\n\t\tprivate long upperLimit;\n\t\tprivate long value;\n\t}\n\n\n\t/**\n\t * Constructs a {@code HiLoOptimizer}\n\t *\n\t * @param returnClass The Java type of the values to be generated\n\t * @param incrementSize The increment size.\n\t */\n\tpublic HiLoOptimizer(Class<?> returnClass, int incrementSize) {\n\t\tsuper( returnClass, incrementSize );\n\t\tif ( incrementSize < 1 ) {\n\t\t\tthrow new HibernateException( \"increment size cannot be less than 1\" );\n\t\t}\n\t\tOPTIMIZER_MESSAGE_LOGGER.creatingHiLoOptimizer( incrementSize, returnClass.getName() );\n\t}\n\n\t@Override\n\tpublic Serializable generate(AccessCallback callback) {\n\t\tlock.lock();\n\t\ttry {\n\t\t\tfinal GenerationState generationState = locateGenerationState( callback.getTenantIdentifier() );\n\n\t\t\tif ( generationState.lastSourceValue == null ) {\n\t\t\t\t// first call, so initialize ourselves.  we need to read the database\n\t\t\t\t// value and set up the 'bucket' boundaries\n\t\t\t\tgenerationState.lastSourceValue = callback.getNextValue();\n\t\t\t\twhile ( generationState.lastSourceValue < 1 ) {\n\t\t\t\t\tgenerationState.lastSourceValue = callback.getNextValue();\n\t\t\t\t}\n\t\t\t\t// upperLimit defines the upper end of the bucket values","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/id/enhanced/HiLoOptimizer.java#L62-L98","documentation":"Error \"increment size cannot be less than 1\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when an identifier optimizer is configured with an increment size smaller than 1.","commonSituations":"Typical situations: setting hibernate.id.optimizer or allocationSize to 0 or a negative value; a mismatched sequence increment combined with an invalid optimizer configuration.","solutions":["Set the generator increment size (allocationSize) to a value >= 1."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}