Skip to content

Commit

Permalink
use hibernate.temp.use_jdbc_metadata_defaults=false everywhere like f…
Browse files Browse the repository at this point in the history
…or HibernateClassic (#641)
  • Loading branch information
jonenst authored Dec 21, 2023
1 parent 3b2839f commit 20b7ec4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected void configureSources(MetadataSources sources) throws DatabaseExceptio
Configuration config = new Configuration(sources);
config.configure(getHibernateConnection().getPath());

config.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false");
config.setProperty(HibernateDatabase.HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS, Boolean.FALSE.toString());
config.setProperty("hibernate.cache.use_second_level_cache", "false");

ServiceRegistry standardRegistry = configuration.getStandardServiceRegistryBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public abstract class HibernateDatabase extends AbstractJdbcDatabase {

private boolean indexesForForeignKeys = false;
public static final String DEFAULT_SCHEMA = "HIBERNATE";
public static final String HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS = "hibernate.temp.use_jdbc_metadata_defaults";

public HibernateDatabase() {
setDefaultCatalogName(DEFAULT_SCHEMA);
Expand Down Expand Up @@ -186,6 +187,7 @@ protected MetadataSources createMetadataSources() throws DatabaseException {

ServiceRegistry standardRegistry = new StandardServiceRegistryBuilder()
.applySetting(AvailableSettings.DIALECT, dialect)
.applySetting(HibernateDatabase.HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS, Boolean.FALSE.toString())
.addService(ConnectionProvider.class, new NoOpConnectionProvider())
.addService(MultiTenantConnectionProvider.class, new NoOpConnectionProvider())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected EntityManagerFactoryBuilderImpl createEntityManagerFactoryBuilder() {
MyHibernatePersistenceProvider persistenceProvider = new MyHibernatePersistenceProvider();

Map<String, Object> properties = new HashMap<>();
properties.put(HibernateDatabase.HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS, Boolean.FALSE.toString());
properties.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, Boolean.FALSE.toString());
properties.put(AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA, getProperty(AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ protected EntityManagerFactoryBuilderImpl createEntityManagerFactoryBuilder() {

Map<String, String> map = new HashMap<>();
map.put(AvailableSettings.DIALECT, getProperty(AvailableSettings.DIALECT));
map.put(HibernateDatabase.HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS, Boolean.FALSE.toString());
map.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, Boolean.FALSE.toString());
map.put(AvailableSettings.PHYSICAL_NAMING_STRATEGY, getHibernateConnection().getProperties().getProperty(AvailableSettings.PHYSICAL_NAMING_STRATEGY));
map.put(AvailableSettings.IMPLICIT_NAMING_STRATEGY, getHibernateConnection().getProperties().getProperty(AvailableSettings.IMPLICIT_NAMING_STRATEGY));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package liquibase.ext.hibernate.database;

import java.util.Collections;
import java.util.Map;

import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
import org.hibernate.jpa.boot.spi.Bootstrap;
Expand Down Expand Up @@ -50,7 +50,8 @@ protected EntityManagerFactoryBuilderImpl createEntityManagerFactoryBuilder() {
internalPersistenceUnitManager.preparePersistenceUnitInfos();
PersistenceUnitInfo persistenceUnitInfo = internalPersistenceUnitManager.obtainDefaultPersistenceUnitInfo();

EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(persistenceUnitInfo, Collections.emptyMap());
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(persistenceUnitInfo, Map.of(
HibernateDatabase.HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS, Boolean.FALSE.toString()));
return builder;
}

Expand Down

0 comments on commit 20b7ec4

Please sign in to comment.