Search in sources :

Example 1 with QDepartment

use of com.querydsl.jpa.domain.QDepartment in project querydsl by querydsl.

the class JPAQueryMixinTest method orderBy_nonRoot_twice.

@Test
public void orderBy_nonRoot_twice() {
    QDepartment department = QDepartment.department;
    QCompany departmentCompany = new QCompany("department_company");
    QEmployee departmentCompanyCeo = 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(departmentCompany)), new JoinExpression(JoinType.LEFTJOIN, departmentCompany.ceo.as(departmentCompanyCeo))), md.getJoins());
    assertEquals(Arrays.asList(departmentCompanyCeo.firstName.asc(), departmentCompanyCeo.lastName.asc()), md.getOrderBy());
}
Also used : QCompany(com.querydsl.jpa.domain.QCompany) QueryMetadata(com.querydsl.core.QueryMetadata) JoinExpression(com.querydsl.core.JoinExpression) QEmployee(com.querydsl.jpa.domain.QEmployee) QDepartment(com.querydsl.jpa.domain.QDepartment) Test(org.junit.Test)

Aggregations

JoinExpression (com.querydsl.core.JoinExpression)1 QueryMetadata (com.querydsl.core.QueryMetadata)1 QCompany (com.querydsl.jpa.domain.QCompany)1 QDepartment (com.querydsl.jpa.domain.QDepartment)1 QEmployee (com.querydsl.jpa.domain.QEmployee)1 Test (org.junit.Test)1