hibernate/hibernate-orm · error · IllegalStateException
Could not locate previous generation state for no-tenant
Error message
Could not locate previous generation state for no-tenant
What it means
Error "Could not locate previous generation state for no-tenant" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledLoOptimizer.java:135
return assignNewStateToTenant( tenantIdentifier );
}
else {
final var state = tenantSpecificState.get( tenantIdentifier );
return state == null
? assignNewStateToTenant( tenantIdentifier )
: state;
}
}
private GenerationState assignNewStateToTenant(String tenantIdentifier) {
final var newState = new GenerationState();
tenantSpecificState.put( tenantIdentifier, newState );
return newState;
}
private GenerationState noTenantGenerationState() {
if ( noTenantState == null ) {
throw new IllegalStateException( "Could not locate previous generation state for no-tenant" );
}
return noTenantState;
}
@Override
public Long getLastSourceValue() {
return noTenantGenerationState().lastSourceValue;
}
@Override
public boolean applyIncrementSizeToSourceValues() {
return true;
}
@Override
public Expression createLowValueExpression(Expression databaseValue, SessionFactoryImplementor sessionFactory) {
return databaseValue;
}View on GitHub (pinned to fad1729dce)
Solutions
- Ensure the sequence/table used by the pooled-lo optimizer exists and is initialized for the no-tenant context.
When it happens
Trigger: Thrown when an identifier optimizer cannot find its previous generation state after the no-tenant state was cleaned up or reset.
Common situations: Typical situations: concurrent id generation while the SessionFactory is shutting down; custom tenant handling that clears the optimizer state; race conditions during schema export.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/c3c98b644a4dc352.
Report an issue: GitHub.