@@ -107,7 +107,7 @@ public <R> R read(Class<R> type, Row row, @Nullable RowMetadata metadata) {
107
107
}
108
108
109
109
if (getConversions ().hasCustomReadTarget (Row .class , rawType )
110
- || getConversionService ().canConvert (Row .class , rawType )) {
110
+ && getConversionService ().canConvert (Row .class , rawType )) {
111
111
return getConversionService ().convert (row , rawType );
112
112
}
113
113
@@ -118,19 +118,21 @@ private <R> R read(RelationalPersistentEntity<R> entity, Row row, @Nullable RowM
118
118
119
119
R result = createInstance (row , metadata , "" , entity );
120
120
121
- ConvertingPropertyAccessor <R > propertyAccessor = new ConvertingPropertyAccessor <>(
122
- entity .getPropertyAccessor (result ), getConversionService ());
121
+ if (entity .requiresPropertyPopulation ()) {
122
+ ConvertingPropertyAccessor <R > propertyAccessor = new ConvertingPropertyAccessor <>(
123
+ entity .getPropertyAccessor (result ), getConversionService ());
123
124
124
- for (RelationalPersistentProperty property : entity ) {
125
+ for (RelationalPersistentProperty property : entity ) {
125
126
126
- if (entity .isConstructorArgument (property )) {
127
- continue ;
128
- }
127
+ if (entity .isConstructorArgument (property )) {
128
+ continue ;
129
+ }
129
130
130
- Object value = readFrom (row , metadata , property , "" );
131
+ Object value = readFrom (row , metadata , property , "" );
131
132
132
- if (value != null ) {
133
- propertyAccessor .setProperty (property , value );
133
+ if (value != null ) {
134
+ propertyAccessor .setProperty (property , value );
135
+ }
134
136
}
135
137
}
136
138
@@ -209,12 +211,15 @@ private <S> S readEntityFrom(Row row, RowMetadata metadata, PersistentProperty<?
209
211
210
212
Object instance = createInstance (row , metadata , prefix , entity );
211
213
212
- PersistentPropertyAccessor <?> accessor = entity .getPropertyAccessor (instance );
213
- ConvertingPropertyAccessor <?> propertyAccessor = new ConvertingPropertyAccessor <>(accessor , getConversionService ());
214
+ if (entity .requiresPropertyPopulation ()) {
215
+ PersistentPropertyAccessor <?> accessor = entity .getPropertyAccessor (instance );
216
+ ConvertingPropertyAccessor <?> propertyAccessor = new ConvertingPropertyAccessor <>(accessor ,
217
+ getConversionService ());
214
218
215
- for (RelationalPersistentProperty p : entity ) {
216
- if (!entity .isConstructorArgument (property )) {
217
- propertyAccessor .setProperty (p , readFrom (row , metadata , p , prefix ));
219
+ for (RelationalPersistentProperty p : entity ) {
220
+ if (!entity .isConstructorArgument (property )) {
221
+ propertyAccessor .setProperty (p , readFrom (row , metadata , p , prefix ));
222
+ }
218
223
}
219
224
}
220
225
@@ -435,7 +440,7 @@ private static Map<String, ColumnMetadata> createMetadataMap(RowMetadata metadat
435
440
private static class RowParameterValueProvider implements ParameterValueProvider <RelationalPersistentProperty > {
436
441
437
442
private final Row resultSet ;
438
- private final @ Nullable RowMetadata metadata ;
443
+ private final RowMetadata metadata ;
439
444
private final RelationalPersistentEntity <?> entity ;
440
445
private final RelationalConverter converter ;
441
446
private final String prefix ;
@@ -458,7 +463,7 @@ public RowParameterValueProvider(Row resultSet, RowMetadata metadata, Relational
458
463
public <T > T getParameterValue (Parameter <T , RelationalPersistentProperty > parameter ) {
459
464
460
465
RelationalPersistentProperty property = this .entity .getRequiredPersistentProperty (parameter .getName ());
461
- String column = this .prefix + property .getColumnName ();
466
+ String column = this .prefix . isEmpty () ? property . getColumnName () : this . prefix + property .getColumnName ();
462
467
463
468
try {
464
469
@@ -472,7 +477,12 @@ public <T> T getParameterValue(Parameter<T, RelationalPersistentProperty> parame
472
477
return null ;
473
478
}
474
479
475
- return this .converter .getConversionService ().convert (value , parameter .getType ().getType ());
480
+ Class <T > type = parameter .getType ().getType ();
481
+
482
+ if (type .isInstance (value )) {
483
+ return type .cast (value );
484
+ }
485
+ return this .converter .getConversionService ().convert (value , type );
476
486
} catch (Exception o_O ) {
477
487
throw new MappingException (String .format ("Couldn't read column %s from Row." , column ), o_O );
478
488
}
0 commit comments