-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关联查询时,每使用关联表的一个条件,就会多一个join #40
Comments
有空就看 |
这是因为,将addresses加到join中时没有过滤重复导致的,把 abstract class AbstractSpecification<T> implements Specification<T>, Serializable {
public String getProperty(String property) {
if (property.contains(".")) {
return StringUtils.split(property, ".")[1];
}
return property;
}
public From getRoot(String property, Root<T> root) {
if (property.contains(".")) {
String joinProperty = StringUtils.split(property, ".")[0];
Set<Join<T, ?>> joins = root.getJoins();
for (Join<T, ?> join : joins) {
if(join.getAttribute().getName().equals(joinProperty)) {
return root;
}
}
return root.join(joinProperty, JoinType.LEFT);
}
return root;
}
} |
老哥,这么做这个条件直接没了啊 |
好的,我看看 |
比如下面的例子
Specification specification = Specifications.and()
.between("age", 10, 35)
.eq("addresses.street", "Chengdu")
.eq("addresses.city", "china")
.build();
用到了addresses的两个条件:street,city,在生成Sql时addresses关联了两次:
如:select * from person left join addresses on x=x left join addresses on x=x ******
这是什么问题呢
The text was updated successfully, but these errors were encountered: