Skip to content

Commit a07a9fc

Browse files
committed
[#1532] fix getBoolean() for Oracle
1 parent 1c37544 commit a07a9fc

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/ResultSetAdaptor.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,23 @@ public String getString(int columnIndex) {
8383

8484
@Override
8585
public boolean getBoolean(int columnIndex) {
86-
Boolean bool = row.getBoolean( columnIndex - 1 );
87-
wasNull = bool == null;
88-
return !wasNull && bool;
86+
try {
87+
Boolean bool = row.getBoolean( columnIndex - 1 );
88+
wasNull = bool == null;
89+
return !wasNull && bool;
90+
}
91+
catch (ClassCastException cce) {
92+
// Oracle doesn't support an actual boolean/Boolean datatype.
93+
// Oracle8iDialect in ORM registers the BOOLEAN type as a 'number( 1, 0 )'
94+
// so we need to convert the int to a boolean
95+
try {
96+
return getInt( columnIndex ) != 0;
97+
}
98+
catch (Exception e) {
99+
// ignore second exception and throw first cce
100+
throw cce;
101+
}
102+
}
89103
}
90104

91105
@Override

0 commit comments

Comments
 (0)