Skip to content

Commit 5917285

Browse files
committed
Improved readability. There seems to be a little logical inconsistency.
1 parent 87aa692 commit 5917285

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,17 @@ private boolean applyPropertyMappings(ResultSetWrapper rsw, ResultMap resultMap,
426426
Object value = getPropertyMappingValue(rsw.getResultSet(), metaObject, propertyMapping, lazyLoader, columnPrefix);
427427
// issue #541 make property optional
428428
final String property = propertyMapping.getProperty();
429-
// issue #377, call setter on nulls
430-
if (value != DEFERED
431-
&& property != null
432-
&& (value != null || (configuration.isCallSettersOnNulls() && !metaObject.getSetterType(property).isPrimitive()))) {
433-
metaObject.setValue(property, value);
434-
}
435-
if (property != null && (value != null || value == DEFERED)) {
429+
if (property == null) {
430+
continue;
431+
} else if (value == DEFERED) {
432+
foundValues = true;
433+
continue;
434+
} else if (value != null) {
436435
foundValues = true;
436+
metaObject.setValue(property, value);
437+
} else if (configuration.isCallSettersOnNulls() && !metaObject.getSetterType(property).isPrimitive()) {
438+
// issue #377, call setter on nulls (value is not 'found')
439+
metaObject.setValue(property, value);
437440
}
438441
}
439442
}
@@ -497,12 +500,13 @@ private boolean applyAutomaticMappings(ResultSetWrapper rsw, ResultMap resultMap
497500
if (autoMapping.size() > 0) {
498501
for (UnMappedColumnAutoMapping mapping : autoMapping) {
499502
final Object value = mapping.typeHandler.getResult(rsw.getResultSet(), mapping.column);
500-
// issue #377, call setter on nulls
501-
if (value != null || configuration.isCallSettersOnNulls()) {
502-
if (value != null || !mapping.primitive) {
503-
metaObject.setValue(mapping.property, value);
504-
}
503+
if (value != null) {
504+
foundValues = true;
505+
metaObject.setValue(mapping.property, value);
506+
} else if (configuration.isCallSettersOnNulls() && !mapping.primitive) {
507+
// issue #377, call setter on nulls
505508
foundValues = true;
509+
metaObject.setValue(mapping.property, value);
506510
}
507511
}
508512
}

0 commit comments

Comments
 (0)