From 4fd94c1fd3475427e6d517f52c42cacffe63c939 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Tue, 18 Feb 2014 22:10:20 -0500 Subject: [PATCH] HHH-8983 log/clear Statement warnings on JdbcCoordinator#release Conflicts: hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java --- .../engine/jdbc/internal/JdbcCoordinatorImpl.java | 4 ++++ .../hibernate/engine/jdbc/spi/SqlExceptionHelper.java | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java index 69e2bee7a5..f66ee0d39a 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java @@ -483,6 +483,10 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator { @SuppressWarnings({ "unchecked" }) protected void close(Statement statement) { LOG.tracev( "Closing prepared statement [{0}]", statement ); + + // Important for Statement caching -- some DBs (especially Sybase) log warnings on every Statement under + // certain situations. + sqlExceptionHelper().logAndClearWarnings( statement ); if ( statement instanceof InvalidatableWrapper ) { InvalidatableWrapper wrapper = ( InvalidatableWrapper ) statement; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java index f1d56fb263..45583f3fb2 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java @@ -28,15 +28,14 @@ import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; -import org.jboss.logging.Logger; -import org.jboss.logging.Logger.Level; - import org.hibernate.JDBCException; import org.hibernate.exception.internal.SQLStateConverter; import org.hibernate.exception.spi.SQLExceptionConverter; import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; +import org.jboss.logging.Logger; +import org.jboss.logging.Logger.Level; /** * Helper for handling SQLExceptions in various manners. @@ -246,6 +245,10 @@ public class SqlExceptionHelper { public void logAndClearWarnings( Connection connection ) { handleAndClearWarnings(connection, STANDARD_WARNING_HANDLER); } + + public void logAndClearWarnings(Statement statement) { + handleAndClearWarnings( statement, STANDARD_WARNING_HANDLER ); + } /** * General purpose handling of warnings associated with a JDBC {@link Connection}. @@ -294,5 +297,4 @@ public class SqlExceptionHelper { LOG.debug("could not clear warnings", sqle); } } - }