[jOOQ/jOOQ#15563] DefaultRecordMapper should skip most mappers when an instance is provided

This commit is contained in:
Lukas Eder 2023-09-08 17:17:00 +02:00
parent 7eedcf1340
commit 312901e7b4

View File

@ -382,16 +382,18 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
return;
}
if (Stream.class.isAssignableFrom(type)) {
delegate = r -> (E) Stream.of(((FieldsImpl<R>) rowType).mapper(configuration, Object[].class).map(r));
return;
}
if (instance == null) {
if (Stream.class.isAssignableFrom(type)) {
delegate = r -> (E) Stream.of(((FieldsImpl<R>) rowType).mapper(configuration, Object[].class).map(r));
return;
}
// [#1470] Return a proxy if the supplied type is an interface
// [#10071] [#11148] Primitive types are abstract! They're mapped by a ConverterProvider only later
if (Modifier.isAbstract(type.getModifiers()) && !type.isPrimitive()) {
delegate = new ProxyMapper();
return;
// [#1470] Return a proxy if the supplied type is an interface
// [#10071] [#11148] Primitive types are abstract! They're mapped by a ConverterProvider only later
if (Modifier.isAbstract(type.getModifiers()) && !type.isPrimitive()) {
delegate = new ProxyMapper();
return;
}
}
// [#2989] [#2836] Records are mapped
@ -401,7 +403,7 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
}
// [#10071] Single-field Record1 types can be mapped if there is a ConverterProvider allowing for this mapping
if ((debugVTFL = fields.length == 1) && (debugVTCP = Tools.converter(configuration, instance, (Class) fields[0].getType(), type) != null)) {
if ((debugVTFL = fields.length == 1) && instance == null && (debugVTCP = Tools.converter(configuration, instance, (Class) fields[0].getType(), type) != null)) {
delegate = new ValueTypeMapper();
return;
}