Search in sources :

Example 1 with QEmployee

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

the class SubQueryTest method innerJoin2.

@Test
public void innerJoin2() {
    QEmployee employee = QEmployee.employee;
    QUser user = QUser.user;
    assertEquals("select employee\nfrom Employee employee\n  inner join employee.user as user", selectFrom(employee).innerJoin(employee.user, user).toString());
}
Also used : QUser(com.querydsl.jpa.domain.QUser) QEmployee(com.querydsl.jpa.domain.QEmployee) Test(org.junit.Test)

Example 2 with QEmployee

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

the class JPACollectionAnyVisitorTest method simple_booleanOperation_elementCollection.

@Test
public void simple_booleanOperation_elementCollection() {
    QEmployee employee = QEmployee.employee;
    Predicate predicate = employee.jobFunctions.any().stringValue().eq("CODER");
    assertEquals("exists (select 1\n" + "from Employee employee_1463394548\n" + "  inner join employee_1463394548.jobFunctions as employee_jobFunctions_0\n" + "where employee_1463394548 = employee and str(employee_jobFunctions_0) = ?1)", serialize(predicate));
}
Also used : QEmployee(com.querydsl.jpa.domain.QEmployee) Predicate(com.querydsl.core.types.Predicate) Test(org.junit.Test)

Example 3 with QEmployee

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

the class JPQLSerializerTest method delete_clause_uses_dELETE_fROM.

@Test
public void delete_clause_uses_dELETE_fROM() {
    QEmployee employee = QEmployee.employee;
    JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
    QueryMetadata md = new DefaultQueryMetadata();
    md.addJoin(JoinType.DEFAULT, employee);
    md.addWhere(employee.lastName.isNull());
    serializer.serializeForDelete(md);
    assertEquals("delete from Employee employee\nwhere employee.lastName is null", serializer.toString());
}
Also used : DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) QEmployee(com.querydsl.jpa.domain.QEmployee) Test(org.junit.Test)

Example 4 with QEmployee

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

the class HibernateQueryTest method innerJoin.

@Test
public void innerJoin() {
    HibernateQuery<?> hqlQuery = new HibernateQuery<Void>();
    QEmployee employee = QEmployee.employee;
    hqlQuery.from(employee);
    hqlQuery.innerJoin(employee.user, QUser.user);
    assertEquals("select employee\nfrom Employee employee\n  inner join employee.user as user", hqlQuery.toString());
}
Also used : HibernateQuery(com.querydsl.jpa.hibernate.HibernateQuery) QEmployee(com.querydsl.jpa.domain.QEmployee) Test(org.junit.Test)

Example 5 with QEmployee

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

QEmployee (com.querydsl.jpa.domain.QEmployee)5 Test (org.junit.Test)5 QueryMetadata (com.querydsl.core.QueryMetadata)2 DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)1 JoinExpression (com.querydsl.core.JoinExpression)1 Predicate (com.querydsl.core.types.Predicate)1 QCompany (com.querydsl.jpa.domain.QCompany)1 QDepartment (com.querydsl.jpa.domain.QDepartment)1 QUser (com.querydsl.jpa.domain.QUser)1 HibernateQuery (com.querydsl.jpa.hibernate.HibernateQuery)1