{"record":{"id":"c3c98b644a4dc352","repo":"hibernate/hibernate-orm","slug":"could-not-locate-previous-generation-state-for-no-c3c98b","errorCode":null,"errorMessage":"Could not locate previous generation state for no-tenant","messagePattern":"Could not locate previous generation state for no-tenant","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledLoOptimizer.java","lineNumber":135,"sourceCode":"\t\t\treturn assignNewStateToTenant( tenantIdentifier );\n\t\t}\n\t\telse {\n\t\t\tfinal var state = tenantSpecificState.get( tenantIdentifier );\n\t\t\treturn state == null\n\t\t\t\t\t? assignNewStateToTenant( tenantIdentifier )\n\t\t\t\t\t: state;\n\t\t}\n\t}\n\n\tprivate GenerationState assignNewStateToTenant(String tenantIdentifier) {\n\t\tfinal var newState = new GenerationState();\n\t\ttenantSpecificState.put( tenantIdentifier, newState );\n\t\treturn newState;\n\t}\n\n\tprivate GenerationState noTenantGenerationState() {\n\t\tif ( noTenantState == null ) {\n\t\t\tthrow new IllegalStateException( \"Could not locate previous generation state for no-tenant\" );\n\t\t}\n\t\treturn noTenantState;\n\t}\n\n\t@Override\n\tpublic Long getLastSourceValue() {\n\t\treturn noTenantGenerationState().lastSourceValue;\n\t}\n\n\t@Override\n\tpublic boolean applyIncrementSizeToSourceValues() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic Expression createLowValueExpression(Expression databaseValue, SessionFactoryImplementor sessionFactory) {\n\t\treturn databaseValue;\n\t}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledLoOptimizer.java#L117-L153","documentation":"Error \"Could not locate previous generation state for no-tenant\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when an identifier optimizer cannot find its previous generation state after the no-tenant state was cleaned up or reset.","commonSituations":"Typical situations: concurrent id generation while the SessionFactory is shutting down; custom tenant handling that clears the optimizer state; race conditions during schema export.","solutions":["Ensure the sequence/table used by the pooled-lo optimizer exists and is initialized for the no-tenant context."],"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"}