From 6745dff1212331a8c8d1757eeb646a7a166fce29 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Mon, 26 Oct 2020 17:12:57 +0000 Subject: [PATCH] HHH-14289 Detection of JDBC support for RefCursors was returning false even for Oracle JDBC drivers supporting it --- .../cursor/internal/StandardRefCursorSupport.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java index c9f882f77f..c8266fc22b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java @@ -137,9 +137,17 @@ public class StandardRefCursorSupport implements RefCursorSupport { */ public static boolean supportsRefCursors(DatabaseMetaData meta) { try { - return meta.supportsRefCursors(); + final boolean mightSupportIt = meta.supportsRefCursors(); + // Some databases cheat and don't actually support it correctly: add some additional checks. + if ( mightSupportIt ) { + if ( "Oracle JDBC driver".equals( meta.getDriverName() ) && meta.getDriverMajorVersion() < 19 ) { + return false; + } + } + return mightSupportIt; } - catch (SQLException throwable) { + catch (Exception throwable) { + //If the driver is not compatible with the Java 8 contract, the method might not exit. log.debug( "Unexpected error trying to gauge level of JDBC REF_CURSOR support : " + throwable.getMessage() ); return false; }