hibernate/hibernate-orm · error · HibernateException
Tenant identifier required
Error message
Tenant identifier required
What it means
Error "Tenant identifier required" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/internal/ContextualJdbcConnectionAccess.java:44
ContextualJdbcConnectionAccess(
Object tenantIdentifier,
boolean readOnly,
SessionEventListener listener,
MultiTenantConnectionProvider<Object> connectionProvider,
SharedSessionContractImplementor session) {
this.tenantIdentifier = tenantIdentifier;
this.readOnly = readOnly;
this.listener = listener;
this.connectionProvider = connectionProvider;
this.session = session;
}
@Override
public Connection obtainConnection() throws SQLException {
if ( tenantIdentifier == null ) {
throw new HibernateException( "Tenant identifier required" );
}
final var eventMonitor = session.getEventMonitor();
final var connectionAcquisitionEvent = eventMonitor.beginJdbcConnectionAcquisitionEvent();
try {
listener.jdbcConnectionAcquisitionStart();
return readOnly
? connectionProvider.getReadOnlyConnection( tenantIdentifier )
: connectionProvider.getConnection( tenantIdentifier );
}
finally {
eventMonitor.completeJdbcConnectionAcquisitionEvent( connectionAcquisitionEvent, session, tenantIdentifier );
listener.jdbcConnectionAcquisitionEnd();
}
}
@Override
public void releaseConnection(Connection connection) throws SQLException {View on GitHub (pinned to fad1729dce)
Solutions
- Provide the tenant identifier when opening the session (e.g. SessionBuilder.tenantIdentifier) in a multi-tenant setup.
When it happens
Trigger: Thrown when multi-tenancy is configured but the required tenant identifier is missing or mismatched.
Common situations: Typical situations: opening a session without a tenant id on a multi-tenant factory; credentials-based multitenancy combined with read-only replicas.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/68502e1f27ef7e94.
Report an issue: GitHub.