HHH-9174 Increase performance

of SqlExceptionHelper#handleAndClearWarnings
Conflicts:
	hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java
This commit is contained in:
Brett Meyer 2014-05-09 12:29:37 -04:00
parent 457937885b
commit 26c7400c0a

View File

@ -313,13 +313,18 @@ public void handleAndClearWarnings(
public void handleAndClearWarnings( public void handleAndClearWarnings(
Statement statement, Statement statement,
WarningHandler handler) { WarningHandler handler) {
try { // See HHH-9174. Statement#getWarnings can be an expensive call for many JDBC libs. Don't do it unless
walkWarnings( statement.getWarnings(), handler ); // the log level would actually allow a warning to be logged.
} if (LOG.isEnabled(Level.WARN)) {
catch (SQLException sqlException) { try {
// workaround for WebLogic walkWarnings( statement.getWarnings(), handler );
LOG.debug( "could not log warnings", sqlException ); }
} catch (SQLException sqlException) {
// workaround for WebLogic
LOG.debug( "could not log warnings", sqlException );
}
}
try { try {
// Sybase fail if we don't do that, sigh... // Sybase fail if we don't do that, sigh...
statement.clearWarnings(); statement.clearWarnings();
@ -328,5 +333,4 @@ public void handleAndClearWarnings(
LOG.debug( "could not clear warnings", sqle ); LOG.debug( "could not clear warnings", sqle );
} }
} }
} }