[jOOQ/jOOQ#11560] java.lang.ClassCastException: class

org.jooq.impl.ResultImpl cannot be cast to class java.sql.ResultSet when
mocking Oracle SYS_REFCURSOR procedure
This commit is contained in:
Lukas Eder 2021-03-03 17:43:43 +01:00
parent 0019713031
commit 53db92e007
2 changed files with 10 additions and 2 deletions

View File

@ -3696,13 +3696,13 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final Result<?> get0(BindingGetResultSetContext<U> ctx) throws SQLException {
ResultSet nested = (ResultSet) ctx.resultSet().getObject(ctx.index());
ResultSet nested = Convert.convert(ctx.resultSet().getObject(ctx.index()), ResultSet.class);
return DSL.using(ctx.configuration()).fetch(nested);
}
@Override
final Result<?> get0(BindingGetStatementContext<U> ctx) throws SQLException {
ResultSet nested = (ResultSet) ctx.statement().getObject(ctx.index());
ResultSet nested = Convert.convert(ctx.statement().getObject(ctx.index()), ResultSet.class);
return DSL.using(ctx.configuration()).fetch(nested);
}

View File

@ -59,6 +59,7 @@ import java.net.URI;
import java.net.URL;
import java.nio.ByteBuffer;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.Struct;
import java.sql.Time;
import java.sql.Timestamp;
@ -92,12 +93,14 @@ import org.jooq.Field;
import org.jooq.JSON;
import org.jooq.JSONB;
import org.jooq.Record;
import org.jooq.Result;
import org.jooq.SQLDialect;
import org.jooq.UDTRecord;
import org.jooq.XML;
import org.jooq.exception.DataTypeException;
import org.jooq.impl.IdentityConverter;
import org.jooq.tools.jdbc.MockArray;
import org.jooq.tools.jdbc.MockResultSet;
import org.jooq.tools.reflect.Reflect;
import org.jooq.types.UByte;
import org.jooq.types.UInteger;
@ -590,6 +593,11 @@ public final class Convert {
return (U) convertArray(fromArray, toClass);
}
// [#11560] Results wrapped in ResultSet
else if (Result.class.isAssignableFrom(fromClass) && toClass == ResultSet.class) {
return (U) new MockResultSet((Result<?>) from);
}
// [#3062] Default collections if no specific collection type was requested
else if (Collection.class.isAssignableFrom(fromClass) ) {
Object[] fromArray = ((Collection<?>) from).toArray();