Search in sources :

Example 1 with QCompany

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

the class AbstractSQLTest method entityQueries7.

@Test
public void entityQueries7() {
    QCompany company = QCompany.company;
    assertEquals(Arrays.asList(), query().from(company).select(company.officialName).fetch());
}
Also used : QCompany(com.querydsl.jpa.domain.QCompany) Test(org.junit.Test)

Example 2 with QCompany

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

the class JPACollectionAnyVisitorTest method nested_any_booleanOperation.

@Test
public void nested_any_booleanOperation() {
    QCompany company = QCompany.company;
    Predicate predicate = company.departments.any().employees.any().firstName.eq("Bob");
    assertEquals("exists (select 1\n" + "from company.departments as company_departments_0\n" + "  inner join company_departments_0.employees as company_departments_0_employees_1\n" + "where company_departments_0_employees_1.firstName = ?1)", serialize(predicate));
}
Also used : QCompany(com.querydsl.jpa.domain.QCompany) Predicate(com.querydsl.core.types.Predicate) Test(org.junit.Test)

Example 3 with QCompany

use of com.querydsl.jpa.domain.QCompany 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

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