@@ -135,10 +135,7 @@ private boolean applyNestedResultMappings(ResultSet rs, ResultMap resultMap, Met
135
135
final String nestedResultMapId = resultMapping .getNestedResultMapId ();
136
136
if (nestedResultMapId != null ) {
137
137
try {
138
- final StringBuilder columnPrefixBuilder = new StringBuilder ();
139
- if (parentPrefix != null ) columnPrefixBuilder .append (parentPrefix );
140
- if (resultMapping .getColumnPrefix () != null ) columnPrefixBuilder .append (resultMapping .getColumnPrefix ());
141
- final String columnPrefix = columnPrefixBuilder .length () == 0 ? null : columnPrefixBuilder .toString ().toUpperCase (Locale .ENGLISH );
138
+ final String columnPrefix = getColumnPrefix (parentPrefix , resultMapping );
142
139
final ResultMap nestedResultMap = getNestedResultMap (rs , nestedResultMapId , columnPrefix );
143
140
final CacheKey rowKey = createRowKey (nestedResultMap , rs , columnPrefix , resultColumnCache );
144
141
final Object ancestorObject = ancestorCache .get (rowKey );
@@ -149,7 +146,7 @@ private boolean applyNestedResultMappings(ResultSet rs, ResultMap resultMap, Met
149
146
Object rowValue = objectCache .get (combinedKey );
150
147
boolean knownValue = (rowValue != null );
151
148
rowValue = getRowValue (rs , nestedResultMap , combinedKey , rowKey , columnPrefix , resultColumnCache , rowValue );
152
- final Object collectionProperty = instantiateCollectionPropertyIfAppropriate (resultMapping , metaObject ); // even if there is no data an empty collection is set
149
+ final Object collectionProperty = instantiateCollectionPropertyIfAppropriate (resultMapping , metaObject );
153
150
if (rowValue != null && !knownValue && anyNotNullColumnHasValue (resultMapping , columnPrefix , rs )) {
154
151
if (collectionProperty != null ) {
155
152
final MetaObject targetMetaObject = configuration .newMetaObject (collectionProperty );
@@ -171,21 +168,29 @@ private boolean applyNestedResultMappings(ResultSet rs, ResultMap resultMap, Met
171
168
}
172
169
return foundValues ;
173
170
}
171
+
172
+ private String getColumnPrefix (String parentPrefix , ResultMapping resultMapping ) {
173
+ final StringBuilder columnPrefixBuilder = new StringBuilder ();
174
+ if (parentPrefix != null ) columnPrefixBuilder .append (parentPrefix );
175
+ if (resultMapping .getColumnPrefix () != null ) columnPrefixBuilder .append (resultMapping .getColumnPrefix ());
176
+ final String columnPrefix = columnPrefixBuilder .length () == 0 ? null : columnPrefixBuilder .toString ().toUpperCase (Locale .ENGLISH );
177
+ return columnPrefix ;
178
+ }
174
179
175
180
private boolean anyNotNullColumnHasValue (ResultMapping resultMapping , String columnPrefix , ResultSet rs ) throws SQLException {
176
181
Set <String > notNullColumns = resultMapping .getNotNullColumns ();
177
- boolean anyNotNullColumnIsNotNull = true ;
182
+ boolean anyNotNullColumnHasValue = true ;
178
183
if (notNullColumns != null && !notNullColumns .isEmpty ()) {
179
- anyNotNullColumnIsNotNull = false ;
184
+ anyNotNullColumnHasValue = false ;
180
185
for (String column : notNullColumns ) {
181
186
rs .getObject (prependPrefix (column , columnPrefix ));
182
187
if (!rs .wasNull ()) {
183
- anyNotNullColumnIsNotNull = true ;
188
+ anyNotNullColumnHasValue = true ;
184
189
break ;
185
190
}
186
191
}
187
192
}
188
- return anyNotNullColumnIsNotNull ;
193
+ return anyNotNullColumnHasValue ;
189
194
}
190
195
191
196
private Object instantiateCollectionPropertyIfAppropriate (ResultMapping resultMapping , MetaObject metaObject ) {
0 commit comments