From 2961f7df68c3b02adb6d984bd6ecbfd62ed7a213 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Tue, 18 Feb 2014 22:08:32 -0500 Subject: [PATCH] HHH-8983 log/clear Statement warnings on JdbcCoordinator#release --- .../hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java | 4 ++++ .../org/hibernate/engine/jdbc/spi/SqlExceptionHelper.java | 4 ++++ 2 files changed, 8 insertions(+) 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 07bd6b449a..63e21fb633 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 @@ -523,6 +523,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 ) { final 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 3955bbead3..73b988271b 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 @@ -268,6 +268,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}.