Skip to content

Commit 859a254

Browse files
committed
Calculate non-cached names on-the-fly
1 parent 0a7af47 commit 859a254

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/main/java/org/apache/ibatis/reflection/ParamNameResolver.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -137,19 +137,15 @@ public Object getNamedParams(Object[] args) {
137137
} else {
138138
final Map<String, Object> param = new ParamMap<>();
139139
int i = 0;
140-
try {
141-
for (Map.Entry<Integer, String> entry : names.entrySet()) {
142-
param.put(entry.getValue(), args[entry.getKey()]);
143-
// add generic param names (param1, param2, ...)
144-
final String genericParamName = GENERIC_NAME_CACHE[i];
145-
// ensure not to overwrite parameter named with @Param
146-
if (!names.containsValue(genericParamName)) {
147-
param.put(genericParamName, args[entry.getKey()]);
148-
}
149-
i++;
140+
for (Map.Entry<Integer, String> entry : names.entrySet()) {
141+
param.put(entry.getValue(), args[entry.getKey()]);
142+
// add generic param names (param1, param2, ...)
143+
final String genericParamName = i < 10 ? GENERIC_NAME_CACHE[i] : GENERIC_NAME_PREFIX + (i + 1);
144+
// ensure not to overwrite parameter named with @Param
145+
if (!names.containsValue(genericParamName)) {
146+
param.put(genericParamName, args[entry.getKey()]);
150147
}
151-
} catch (ArrayIndexOutOfBoundsException e) {
152-
throw new ArrayIndexOutOfBoundsException("The parameter list is too long, the maximum supported length is 10");
148+
i++;
153149
}
154150
return param;
155151
}

0 commit comments

Comments
 (0)