First of all, thanks for all your work on providing Hibernate.
I’m using Hibernate with multitenancy on Wildfly. The connection provider is DataSourceBasedMultiTenantConnectionProviderImpl and the related property in persistence.xml for this issue is hibernate.connection.datasource.
Everything worked fine on Hibernate 5.3.14. Later versions, used on on Wildfly 17, 18, 19, 20, did not work. What I got was a NPE: org.hibernate.internal.ContextualJdbcConnectionAccess.supportsAggressiveRelease(ContextualJdbcConnectionAccess:67)
.
Turns out that with HHH-12858 my hibernate.connection.datasource property is overridden by the default datasource that Wildfly provides and that causes the MultiTenantConnectionProvider to be initiated to null. Once that is known the issue is easily fixed by removing the datasource default-binding.
However, it took a while to figure this out and I have two thoughts.
- There might be other considerations, but shouldn’t user provided hibernate.connection.datasource in persistence.xml override the default datasource binding provided by the container (JPA 2.0 8.2.1.5)?
- When the user doesn’t specify MultiTenantConnectionProvider, the MultiTenantConnectionProviderInitiator will assume that DataSourceBasedMultiTenantConnectionProviderImpl is wanted, but then just gives up and returns null if the hibernate.connection.datasource is not set or is set, but not with a String value (which happened in my case when it was replaced with the data source provided by Wildfly). An exception or a user message here would have helped a lot in finding the cause.
Let me know if there is anything I can do.