Environment.MULTI_TENANT and createSQLQuery() not found hibernate 6.1.6Final

Hello, after an upgrade from Hibernate 5 to Hibernate 6 (6.1.16), I have some issues.

Here is my old configuration:

jpaPropertiesMap.put(Environment.MULTI_TENANT, MultiTenancyStrategy.DATABASE);
        jpaPropertiesMap.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
        jpaPropertiesMap.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);
        jpaPropertiesMap.put(Environment.FORMAT_SQL, true);
        jpaPropertiesMap.put(Environment.SHOW_SQL, true);

Since the upgrade, I can’t find the imports for the first line jpaPropertiesMap.put(Environment.MULTI_TENANT, MultiTenancyStrategy.DATABASE); or what to replace it with

Also, in the past I retrieved the name of the current database with the following query. Since the upgrade this does not work anymore, the createSQLQuery() is not found, I did not find what to replace it with either.

String nomBdd = (String) entityManager.unwrap(Session.class).createSQLQuery("SELECT DATABASE()").uniqueResult();

Thank you for your help with the two points mentioned

Environment is an internal class. You should rather use AvailableSettings on which all settings are declared. The MULTI_TENANT option was dropped as it was unnecessary. You can just omit that.
createSQLQuery was deprecated since version 5.2 and replaced with createNativeQuery.

2 Likes