mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Fix issue with order by expressions for non root paths
This commit is contained in:
parent
3928a8b6ff
commit
e100e9800a
@ -146,6 +146,7 @@ public class JPAQueryMixin<T> extends QueryMixin<T> {
|
||||
Path<T> oldPath = new PathImpl<T>(path.getType(),
|
||||
new PathMetadata(parent, metadata.getElement(), metadata.getPathType()));
|
||||
Path<T> newPath = new PathImpl<T>(type, oldPath.toString().replace('.', '_'));
|
||||
aliases.put(path, newPath);
|
||||
leftJoin(oldPath, newPath);
|
||||
return newPath;
|
||||
}
|
||||
|
||||
@ -13,6 +13,9 @@ import com.querydsl.core.types.PathMetadataFactory;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.jpa.domain.QCat;
|
||||
import com.querydsl.jpa.domain.QCompany;
|
||||
import com.querydsl.jpa.domain.QDepartment;
|
||||
import com.querydsl.jpa.domain.QEmployee;
|
||||
import com.querydsl.jpa.domain4.QBookMark;
|
||||
import com.querydsl.jpa.domain4.QBookVersion;
|
||||
|
||||
@ -41,6 +44,24 @@ public class JPAQueryMixinTest {
|
||||
md.getOrderBy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void OrderBy_NonRoot_Twice() {
|
||||
QDepartment department = QDepartment.department;
|
||||
QCompany department_company = new QCompany("department_company");
|
||||
QEmployee department_company_ceo = new QEmployee("department_company_ceo");
|
||||
mixin.from(department);
|
||||
mixin.orderBy(department.company.ceo.firstName.asc(), department.company.ceo.lastName.asc());
|
||||
|
||||
QueryMetadata md = mixin.getMetadata();
|
||||
assertEquals(Arrays.asList(
|
||||
new JoinExpression(JoinType.DEFAULT, department),
|
||||
new JoinExpression(JoinType.LEFTJOIN, department.company.as(department_company)),
|
||||
new JoinExpression(JoinType.LEFTJOIN, department_company.ceo.as(department_company_ceo))),
|
||||
md.getJoins());
|
||||
assertEquals(Arrays.asList(department_company_ceo.firstName.asc(), department_company_ceo.lastName.asc()),
|
||||
md.getOrderBy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void OrderBy_Where() {
|
||||
QCat cat = QCat.cat;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user