{"record":{"id":"053ecffcb4899127","repo":"hibernate/hibernate-orm","slug":"increment-size-cannot-be-less-than-1-053ecf","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/LegacyHiLoAlgorithmOptimizer.java","lineNumber":51,"sourceCode":"\tprivate static class GenerationState {\n\t\tprivate long maxLo;\n\t\tprivate long lo;\n\t\tprivate long hi;\n\n\t\tprivate Long lastSourceValue;\n\t\tprivate long value;\n\t}\n\n\t/**\n\t * Constructs a {@code LegacyHiLoAlgorithmOptimizer}\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 LegacyHiLoAlgorithmOptimizer(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.creatingLegacyHiLoOptimizer( incrementSize, returnClass.getName() );\n\t\tinitialMaxLo = incrementSize;\n\t}\n\n\t@Override\n\tpublic Serializable generate(AccessCallback callback) {\n\t\tlock.lock();\n\t\ttry {\n\t\t\tfinal var generationState = locateGenerationState( callback.getTenantIdentifier() );\n\t\t\tif ( generationState.lo > generationState.maxLo ) {\n\t\t\t\tgenerationState.lastSourceValue = callback.getNextValue();\n\t\t\t\tgenerationState.lo = generationState.lastSourceValue == 0 ? 1 : 0;\n\t\t\t\tgenerationState.hi = generationState.lastSourceValue * ( generationState.maxLo + 1 );\n\t\t\t}\n\t\t\tgenerationState.value = generationState.hi + generationState.lo++;\n\t\t\treturn makeIntegralValue( generationState.value, returnClass );\n\t\t}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/id/enhanced/LegacyHiLoAlgorithmOptimizer.java#L33-L69","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"}