I'm using schema based multi-tenancy providing implementations for both MultiTenantConnectionProvider & CurrentTenantIdentifierResolver. Trying to get a hibernate session for a single tenant fails with an NPE.
Looking into the source code, it seems that JDBCServicesImpl initializes the connectionProvider to null in the else block
private JdbcConnectionAccess buildJdbcConnectionAccess(Map configValues) {
final MultiTenancyStrategy multiTenancyStrategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configValues );
if ( MultiTenancyStrategy.NONE == multiTenancyStrategy ) {
connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
return new ConnectionProviderJdbcConnectionAccess( connectionProvider );
}
else {
connectionProvider = null;
final MultiTenantConnectionProvider multiTenantConnectionProvider = serviceRegistry.getService( MultiTenantConnectionProvider.class );
return new MultiTenantConnectionProviderJdbcConnectionAccess( multiTenantConnectionProvider );
}
}
There was a similar issue raised in the past HHH-7389 but it was closed because it was missing a test case to reproduce the issue. Please find the test case attached for reproducing the bug.
|