Browse Source

Consistent use of AvailableSettings instead of Environment

Issue: SPR-14548
pull/1132/head
Juergen Hoeller 8 years ago
parent
commit
36143692ac
  1. 5
      spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java
  2. 9
      spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java

5
spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java

@ -42,7 +42,6 @@ import org.hibernate.boot.MetadataSources; @@ -42,7 +42,6 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -138,9 +137,9 @@ public class LocalSessionFactoryBuilder extends Configuration { @@ -138,9 +137,9 @@ public class LocalSessionFactoryBuilder extends Configuration {
public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader, MetadataSources metadataSources) {
super(metadataSources);
getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
if (dataSource != null) {
getProperties().put(Environment.DATASOURCE, dataSource);
getProperties().put(AvailableSettings.DATASOURCE, dataSource);
}
// Hibernate 5.1/5.2: manually enforce connection release mode ON_CLOSE (the former default)

9
spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java vendored

@ -23,7 +23,6 @@ import javax.persistence.EntityManagerFactory; @@ -23,7 +23,6 @@ import javax.persistence.EntityManagerFactory;
import javax.persistence.spi.PersistenceProvider;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.DerbyTenSevenDialect;
import org.hibernate.dialect.H2Dialect;
@ -108,20 +107,20 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter { @@ -108,20 +107,20 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
Map<String, Object> jpaProperties = new HashMap<>();
if (getDatabasePlatform() != null) {
jpaProperties.put(Environment.DIALECT, getDatabasePlatform());
jpaProperties.put(AvailableSettings.DIALECT, getDatabasePlatform());
}
else if (getDatabase() != null) {
Class<?> databaseDialectClass = determineDatabaseDialectClass(getDatabase());
if (databaseDialectClass != null) {
jpaProperties.put(Environment.DIALECT, databaseDialectClass.getName());
jpaProperties.put(AvailableSettings.DIALECT, databaseDialectClass.getName());
}
}
if (isGenerateDdl()) {
jpaProperties.put(Environment.HBM2DDL_AUTO, "update");
jpaProperties.put(AvailableSettings.HBM2DDL_AUTO, "update");
}
if (isShowSql()) {
jpaProperties.put(Environment.SHOW_SQL, "true");
jpaProperties.put(AvailableSettings.SHOW_SQL, "true");
}
if (this.jpaDialect.prepareConnection) {

Loading…
Cancel
Save