java - Hibernate multitenancy test fails with NPE -
i'm using schema based multi-tenancy providing implementations both multitenantconnectionprovider & currenttenantidentifierresolver. trying hibernate session single tenant fails npe. looking hibernate's source code, seems jdbcservicesimpl initializes connectionprovider null in 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 ); } }
please find test case here - http://pastebin.com/7mt9wtht , stacktrace - http://pastebin.com/8ygau7eh
is there basic missing out?
well, after looking @ source code awhile now. hibernate (as now) not support schema export. taken documentation.
currently schema export not work multi-tenancy. may not change
so, in case, fix remove line
config.getproperties().put(availablesettings.hbm2ddl_auto, "validate");