HHH-10484 - Add Dialect#isJdbcLogWarningsEnabledByDefault() method, the return value is true
This commit is contained in:
parent
1a1523db44
commit
624ddc620b
|
@ -594,7 +594,7 @@ public interface AvailableSettings {
|
|||
* Enable fetching JDBC statement warning for logging.
|
||||
*
|
||||
* Values are {@code true} or {@code false} .
|
||||
* Default value is {@code false}
|
||||
* Default value is {@link org.hibernate.dialect.Dialect#isJdbcLogWarningsEnabledByDefault()}
|
||||
*
|
||||
* @since 5.1
|
||||
*/
|
||||
|
|
|
@ -2723,4 +2723,15 @@ public abstract class Dialect implements ConversionContext {
|
|||
public BatchLoadSizingStrategy getDefaultBatchLoadSizingStrategy() {
|
||||
return STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the fetching JDBC statement warning for logging is enabled by default
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 5.1
|
||||
*/
|
||||
public boolean isJdbcLogWarningsEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
|||
}
|
||||
this.nameQualifierSupport = nameQualifierSupport;
|
||||
|
||||
this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, logWarnings( cfgService ) );
|
||||
this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, logWarnings( cfgService, dialect ) );
|
||||
this.extractedMetaDataSupport = new ExtractedDatabaseMetaDataImpl.Builder( this ).build();
|
||||
|
||||
final IdentifierHelperBuilder identifierHelperBuilder = IdentifierHelperBuilder.from( this );
|
||||
|
@ -108,11 +108,11 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
|||
this.lobCreatorBuilder = LobCreatorBuilderImpl.makeLobCreatorBuilder();
|
||||
}
|
||||
|
||||
private static boolean logWarnings(ConfigurationService cfgService) {
|
||||
private static boolean logWarnings(ConfigurationService cfgService, Dialect dialect) {
|
||||
return cfgService.getSetting(
|
||||
AvailableSettings.LOG_JDBC_WARNINGS,
|
||||
StandardConverters.BOOLEAN,
|
||||
false
|
||||
dialect.isJdbcLogWarningsEnabledByDefault()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
|||
|
||||
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
|
||||
this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, logWarnings( cfgService ) );
|
||||
this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, logWarnings( cfgService, dialect ) );
|
||||
|
||||
this.extractedMetaDataSupport = new ExtractedDatabaseMetaDataImpl.Builder( this )
|
||||
.apply( databaseMetaData )
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
|
||||
|
@ -69,15 +70,11 @@ class ManagedProviderConnectionHelper implements ConnectionHelper {
|
|||
private void releaseConnection() throws SQLException {
|
||||
if ( connection != null ) {
|
||||
try {
|
||||
final boolean logWarning = ConfigurationHelper.getBoolean(
|
||||
AvailableSettings.LOG_JDBC_WARNINGS,
|
||||
cfgProperties,
|
||||
false
|
||||
);
|
||||
new SqlExceptionHelper( logWarning ).logAndClearWarnings( connection );
|
||||
serviceRegistry.getService( JdbcEnvironment.class ).getSqlExceptionHelper().logAndClearWarnings(
|
||||
connection );
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
try {
|
||||
serviceRegistry.getService( ConnectionProvider.class ).closeConnection( connection );
|
||||
}
|
||||
finally {
|
||||
|
|
Loading…
Reference in New Issue