@@ -46,6 +46,7 @@ public class ResultMap {
46
46
private Set <String > mappedColumns ;
47
47
private Set <String > mappedProperties ;
48
48
private Discriminator discriminator ;
49
+ private boolean hasResultMapsUsingConstructorCollection ;
49
50
private boolean hasNestedResultMaps ;
50
51
private boolean hasNestedQueries ;
51
52
private Boolean autoMapping ;
@@ -63,7 +64,7 @@ public Builder(Configuration configuration, String id, Class<?> type, List<Resul
63
64
}
64
65
65
66
public Builder (Configuration configuration , String id , Class <?> type , List <ResultMapping > resultMappings ,
66
- Boolean autoMapping ) {
67
+ Boolean autoMapping ) {
67
68
resultMap .configuration = configuration ;
68
69
resultMap .id = id ;
69
70
resultMap .type = type ;
@@ -111,6 +112,14 @@ public ResultMap build() {
111
112
}
112
113
if (resultMapping .getFlags ().contains (ResultFlag .CONSTRUCTOR )) {
113
114
resultMap .constructorResultMappings .add (resultMapping );
115
+
116
+ //#101
117
+ if (resultMap .configuration .isExperimentalConstructorCollectionMappingEnabled ()) {
118
+ Class <?> javaType = resultMapping .getJavaType ();
119
+ resultMap .hasResultMapsUsingConstructorCollection = resultMap .hasResultMapsUsingConstructorCollection
120
+ || (javaType != null && resultMap .configuration .getObjectFactory ().isCollection (javaType ));
121
+ }
122
+
114
123
if (resultMapping .getProperty () != null ) {
115
124
constructorArgNames .add (resultMapping .getProperty ());
116
125
}
@@ -136,6 +145,12 @@ public ResultMap build() {
136
145
int paramIdx2 = actualArgNames .indexOf (o2 .getProperty ());
137
146
return paramIdx1 - paramIdx2 ;
138
147
});
148
+
149
+ //#101
150
+ if (resultMap .configuration .isExperimentalConstructorCollectionMappingEnabled ()) {
151
+ resultMap .hasResultMapsUsingConstructorCollection = resultMap .constructorResultMappings .stream ()
152
+ .map (ResultMapping ::getJavaType ).anyMatch (resultMap .configuration .getObjectFactory ()::isCollection );
153
+ }
139
154
}
140
155
// lock down collections
141
156
resultMap .resultMappings = Collections .unmodifiableList (resultMap .resultMappings );
@@ -211,9 +226,7 @@ public String getId() {
211
226
}
212
227
213
228
public boolean hasResultMapsUsingConstructorCollection () {
214
- return configuration .isExperimentalConstructorCollectionMappingEnabled ()
215
- && this .constructorResultMappings .stream ().filter (crm -> crm .getNestedQueryId () == null )
216
- .map (ResultMapping ::getJavaType ).anyMatch (configuration .getObjectFactory ()::isCollection );
229
+ return hasResultMapsUsingConstructorCollection ;
217
230
}
218
231
219
232
public boolean hasNestedResultMaps () {
0 commit comments