diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java index eeef6ac613..28ba5645da 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java @@ -291,7 +291,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett * * @since 5.2.10 */ - String CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT= "hibernate.connection.provider_disables_autocommit"; + String CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT = "hibernate.connection.provider_disables_autocommit"; /** * A prefix for properties specifying arbitrary JDBC connection properties. These diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java index 5f3172e453..2ecd5e5fd4 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java @@ -16,6 +16,7 @@ import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.DatabaseConnectionInfo; import org.hibernate.engine.jndi.spi.JndiService; +import org.hibernate.internal.log.ConnectionInfoLogger; import org.hibernate.service.UnknownUnwrapTypeException; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.InjectService; @@ -87,8 +88,8 @@ public class DatasourceConnectionProviderImpl implements ConnectionProvider, Con public void configure(Map configValues) { if ( dataSource == null ) { final Object dataSourceSetting = configValues.get( DATASOURCE ); - if ( dataSourceSetting instanceof DataSource ) { - dataSource = (DataSource) dataSourceSetting; + if ( dataSourceSetting instanceof DataSource ds ) { + dataSource = ds; } else { final String dataSourceJndiName = (String) dataSourceSetting; @@ -109,6 +110,15 @@ public class DatasourceConnectionProviderImpl implements ConnectionProvider, Con throw new HibernateException( "Unable to determine appropriate DataSource to use" ); } + if ( configValues.containsKey( AvailableSettings.AUTOCOMMIT ) ) { + ConnectionInfoLogger.INSTANCE.ignoredSetting( AvailableSettings.AUTOCOMMIT, + DatasourceConnectionProviderImpl.class ); + } + if ( configValues.containsKey( AvailableSettings.ISOLATION ) ) { + ConnectionInfoLogger.INSTANCE.ignoredSetting( AvailableSettings.ISOLATION, + DatasourceConnectionProviderImpl.class ); + } + user = (String) configValues.get( AvailableSettings.USER ); pass = (String) configValues.get( AvailableSettings.PASS ); useCredentials = user != null || pass != null; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionInfoLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionInfoLogger.java index 2c97209c4f..d5ade897b2 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionInfoLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionInfoLogger.java @@ -49,7 +49,7 @@ public interface ConnectionInfoLogger extends BasicLogger { @Message(id = 10001006, value = "No JDBC Driver class was specified by property '" + JdbcSettings.JAKARTA_JDBC_DRIVER + "', '" - + JdbcSettings.JPA_JDBC_DRIVER + "', or '" + + JdbcSettings.JPA_JDBC_DRIVER + "', or '" + JdbcSettings.DRIVER + "'") void jdbcDriverNotSpecified(); @@ -72,4 +72,8 @@ public interface ConnectionInfoLogger extends BasicLogger { @LogMessage(level = DEBUG) @Message(value = "Configuring connection pool [%s]", id = 10001012) void configureConnectionPool(String type); + + @LogMessage(level = INFO) + @Message(value = "Ignoring setting '%s' for connection provider [%s]", id = 10001013) + void ignoredSetting(String setting, Class provider); }