log warnings when settings are ignored for Datasource
This commit is contained in:
parent
0531454f88
commit
6cfcee5e4b
|
@ -291,7 +291,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
|
||||||
*
|
*
|
||||||
* @since 5.2.10
|
* @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
|
* A prefix for properties specifying arbitrary JDBC connection properties. These
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.DatabaseConnectionInfo;
|
import org.hibernate.engine.jdbc.connections.spi.DatabaseConnectionInfo;
|
||||||
import org.hibernate.engine.jndi.spi.JndiService;
|
import org.hibernate.engine.jndi.spi.JndiService;
|
||||||
|
import org.hibernate.internal.log.ConnectionInfoLogger;
|
||||||
import org.hibernate.service.UnknownUnwrapTypeException;
|
import org.hibernate.service.UnknownUnwrapTypeException;
|
||||||
import org.hibernate.service.spi.Configurable;
|
import org.hibernate.service.spi.Configurable;
|
||||||
import org.hibernate.service.spi.InjectService;
|
import org.hibernate.service.spi.InjectService;
|
||||||
|
@ -87,8 +88,8 @@ public class DatasourceConnectionProviderImpl implements ConnectionProvider, Con
|
||||||
public void configure(Map<String, Object> configValues) {
|
public void configure(Map<String, Object> configValues) {
|
||||||
if ( dataSource == null ) {
|
if ( dataSource == null ) {
|
||||||
final Object dataSourceSetting = configValues.get( DATASOURCE );
|
final Object dataSourceSetting = configValues.get( DATASOURCE );
|
||||||
if ( dataSourceSetting instanceof DataSource ) {
|
if ( dataSourceSetting instanceof DataSource ds ) {
|
||||||
dataSource = (DataSource) dataSourceSetting;
|
dataSource = ds;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final String dataSourceJndiName = (String) dataSourceSetting;
|
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" );
|
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 );
|
user = (String) configValues.get( AvailableSettings.USER );
|
||||||
pass = (String) configValues.get( AvailableSettings.PASS );
|
pass = (String) configValues.get( AvailableSettings.PASS );
|
||||||
useCredentials = user != null || pass != null;
|
useCredentials = user != null || pass != null;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public interface ConnectionInfoLogger extends BasicLogger {
|
||||||
@Message(id = 10001006,
|
@Message(id = 10001006,
|
||||||
value = "No JDBC Driver class was specified by property '"
|
value = "No JDBC Driver class was specified by property '"
|
||||||
+ JdbcSettings.JAKARTA_JDBC_DRIVER + "', '"
|
+ JdbcSettings.JAKARTA_JDBC_DRIVER + "', '"
|
||||||
+ JdbcSettings.JPA_JDBC_DRIVER + "', or '"
|
+ JdbcSettings.JPA_JDBC_DRIVER + "', or '"
|
||||||
+ JdbcSettings.DRIVER + "'")
|
+ JdbcSettings.DRIVER + "'")
|
||||||
void jdbcDriverNotSpecified();
|
void jdbcDriverNotSpecified();
|
||||||
|
|
||||||
|
@ -72,4 +72,8 @@ public interface ConnectionInfoLogger extends BasicLogger {
|
||||||
@LogMessage(level = DEBUG)
|
@LogMessage(level = DEBUG)
|
||||||
@Message(value = "Configuring connection pool [%s]", id = 10001012)
|
@Message(value = "Configuring connection pool [%s]", id = 10001012)
|
||||||
void configureConnectionPool(String type);
|
void configureConnectionPool(String type);
|
||||||
|
|
||||||
|
@LogMessage(level = INFO)
|
||||||
|
@Message(value = "Ignoring setting '%s' for connection provider [%s]", id = 10001013)
|
||||||
|
void ignoredSetting(String setting, Class<?> provider);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue