mirror of https://github.com/elunez/eladmin
修复关联查询出现重复的join:https://github.com/elunez/eladmin/issues/655
close https://github.com/elunez/eladmin/issues/655pull/805/head
parent
cf3655adf4
commit
b46d50fef1
|
@ -53,6 +53,7 @@ public class QueryHelp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Map<String, Join> joinKey = new HashMap<>();
|
||||||
List<Field> fields = getAllFields(query.getClass(), new ArrayList<>());
|
List<Field> fields = getAllFields(query.getClass(), new ArrayList<>());
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
boolean accessible = field.isAccessible();
|
boolean accessible = field.isAccessible();
|
||||||
|
@ -75,14 +76,15 @@ public class QueryHelp {
|
||||||
String[] blurrys = blurry.split(",");
|
String[] blurrys = blurry.split(",");
|
||||||
List<Predicate> orPredicate = new ArrayList<>();
|
List<Predicate> orPredicate = new ArrayList<>();
|
||||||
for (String s : blurrys) {
|
for (String s : blurrys) {
|
||||||
orPredicate.add(cb.like(root.get(s)
|
orPredicate.add(cb.like(root.get(s).as(String.class), "%" + val.toString() + "%"));
|
||||||
.as(String.class), "%" + val.toString() + "%"));
|
|
||||||
}
|
}
|
||||||
Predicate[] p = new Predicate[orPredicate.size()];
|
Predicate[] p = new Predicate[orPredicate.size()];
|
||||||
list.add(cb.or(orPredicate.toArray(p)));
|
list.add(cb.or(orPredicate.toArray(p)));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotEmpty(joinName)) {
|
if (ObjectUtil.isNotEmpty(joinName)) {
|
||||||
|
join = joinKey.get(joinName);
|
||||||
|
if(join == null){
|
||||||
String[] joinNames = joinName.split(">");
|
String[] joinNames = joinName.split(">");
|
||||||
for (String name : joinNames) {
|
for (String name : joinNames) {
|
||||||
switch (q.join()) {
|
switch (q.join()) {
|
||||||
|
@ -110,6 +112,8 @@ public class QueryHelp {
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
joinKey.put(joinName, join);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (q.type()) {
|
switch (q.type()) {
|
||||||
case EQUAL:
|
case EQUAL:
|
||||||
|
|
Loading…
Reference in New Issue