Skip to content

Commit a8bad69

Browse files
committed
SQL JOIN:解决副表除了引用赋值键值对还有其它条件键值对时不能命中缓存,导致 一对多、多对多副表数据重复 以及 一对一、多对一 查询性能问题
1 parent 00dae1b commit a8bad69

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,18 +2197,42 @@ else if (prior && andList.isEmpty() == false) {
21972197
String userIdKey = getUserIdKey();
21982198
String userIdInKey = userIdKey + "{}";
21992199

2200-
if (andList.contains(idKey)) {
2201-
i ++;
2200+
int lastIndex;
2201+
if (key.equals(idKey)) {
2202+
lastIndex = -1;
22022203
}
2203-
if (andList.contains(idInKey)) {
2204-
i ++;
2204+
else if (key.equals(idInKey)) {
2205+
lastIndex = andList.lastIndexOf(idKey);
22052206
}
2206-
if (andList.contains(userIdKey)) {
2207-
i ++;
2207+
else if (key.equals(userIdKey)) {
2208+
lastIndex = andList.lastIndexOf(idInKey);
2209+
if (lastIndex < 0) {
2210+
lastIndex = andList.lastIndexOf(idKey);
2211+
}
22082212
}
2209-
if (andList.contains(userIdInKey)) {
2210-
i ++;
2213+
else if (key.equals(userIdInKey)) {
2214+
lastIndex = andList.lastIndexOf(userIdKey);
2215+
if (lastIndex < 0) {
2216+
lastIndex = andList.lastIndexOf(idInKey);
2217+
}
2218+
if (lastIndex < 0) {
2219+
lastIndex = andList.lastIndexOf(idKey);
2220+
}
2221+
}
2222+
else {
2223+
lastIndex = andList.lastIndexOf(userIdInKey);
2224+
if (lastIndex < 0) {
2225+
lastIndex = andList.lastIndexOf(userIdKey);
2226+
}
2227+
if (lastIndex < 0) {
2228+
lastIndex = andList.lastIndexOf(idInKey);
2229+
}
2230+
if (lastIndex < 0) {
2231+
lastIndex = andList.lastIndexOf(idKey);
2232+
}
22112233
}
2234+
2235+
i = lastIndex + 1;
22122236
}
22132237

22142238
if (prior) {
@@ -2219,6 +2243,7 @@ else if (prior && andList.isEmpty() == false) {
22192243
}
22202244
combine.put("&", andList);
22212245
}
2246+
22222247
return this;
22232248
}
22242249

0 commit comments

Comments
 (0)