Skip to content

Commit 4cf537c

Browse files
committed
minor optimization
1 parent 037dafd commit 4cf537c

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,22 @@ private boolean applyNestedResultMappings(ResultSet rs, ResultMap resultMap, Met
145145
final CacheKey combinedKey = combineKeys(rowKey, parentRowKey);
146146
Object rowValue = objectCache.get(combinedKey);
147147
boolean knownValue = (rowValue != null);
148-
rowValue = getRowValue(rs, nestedResultMap, combinedKey, rowKey, columnPrefix, resultColumnCache, rowValue);
149-
final Object collectionProperty = instantiateCollectionPropertyIfAppropriate(resultMapping, metaObject);
150-
if (rowValue != null && !knownValue && anyNotNullColumnHasValue(resultMapping, columnPrefix, rs)) {
151-
if (collectionProperty != null) {
152-
final MetaObject targetMetaObject = configuration.newMetaObject(collectionProperty);
153-
targetMetaObject.add(rowValue);
154-
} else {
155-
if (!newObject) {
156-
throw new ExecutorException("Trying to overwrite a previous set value for the association '" + resultMapping.getProperty()
157-
+ "'. Check your id/result elements to ensure they identify uniquely an record.");
148+
final Object collectionProperty = instantiateCollectionPropertyIfAppropriate(resultMapping, metaObject);
149+
if (anyNotNullColumnHasValue(resultMapping, columnPrefix, rs)) {
150+
rowValue = getRowValue(rs, nestedResultMap, combinedKey, rowKey, columnPrefix, resultColumnCache, rowValue);
151+
if (rowValue != null && !knownValue) {
152+
if (collectionProperty != null) {
153+
final MetaObject targetMetaObject = configuration.newMetaObject(collectionProperty);
154+
targetMetaObject.add(rowValue);
155+
} else {
156+
if (!newObject) {
157+
throw new ExecutorException("Trying to overwrite a previous set value for the association '" + resultMapping.getProperty()
158+
+ "'. Check your id/result elements to ensure they identify uniquely an record.");
159+
}
160+
metaObject.setValue(resultMapping.getProperty(), rowValue);
158161
}
159-
metaObject.setValue(resultMapping.getProperty(), rowValue);
162+
foundValues = true;
160163
}
161-
foundValues = true;
162164
}
163165
}
164166
} catch (SQLException e) {

0 commit comments

Comments
 (0)