From bbb2df4f2782679e5f742f1dc9f0fbbcbd316603 Mon Sep 17 00:00:00 2001 From: Barry LaFond Date: Tue, 4 Apr 2023 12:24:40 -0500 Subject: [PATCH] [#1532] fix getBoolean() for Oracle --- .../adaptor/impl/ResultSetAdaptor.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/ResultSetAdaptor.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/ResultSetAdaptor.java index 58b16b6102..fbbfe50521 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/ResultSetAdaptor.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/ResultSetAdaptor.java @@ -83,9 +83,23 @@ public String getString(int columnIndex) { @Override public boolean getBoolean(int columnIndex) { - Boolean bool = row.getBoolean( columnIndex - 1 ); - wasNull = bool == null; - return !wasNull && bool; + try { + Boolean bool = row.getBoolean( columnIndex - 1 ); + wasNull = bool == null; + return !wasNull && bool; + } + catch (ClassCastException cce) { + // Oracle doesn't support an actual boolean/Boolean datatype. + // Oracle8iDialect in ORM registers the BOOLEAN type as a 'number( 1, 0 )' + // so we need to convert the int to a boolean + try { + return getInt( columnIndex ) != 0; + } + catch (Exception e) { + // ignore second exception and throw first cce + throw cce; + } + } } @Override