NPE

时间:2015-04-23 05:49:09

标签: java hibernate nullpointerexception hibernate-4.x multi-tenant

我正在使用基于模式的多租户,为MultiTenantConnectionProvider& CurrentTenantIdentifierResolver。尝试为单个租户获得休眠会话会因NPE而失败。 查看hibernate的源代码,似乎JDBCServicesImpl在else块中将connectionProvider初始化为null

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 );
    }
}

请在此处找到此测试用例 - http://pastebin.com/7Mt9wtHt及其堆栈跟踪 - http://pastebin.com/8ygAu7eh

我错过了一些基本的东西吗?

1 个答案:

答案 0 :(得分:0)

我也面临同样的问题。当我用Google搜索时,在hibernate中发布了一个错误。 这是链接https://hibernate.atlassian.net/browse/HHH-7395