Search in sources :

Example 16 with QEmployee

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

the class UpdateBase method update_with_subQuery_exists2.

@Test
public void update_with_subQuery_exists2() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLUpdateClause update = update(survey1);
    update.set(survey1.name, "AA");
    update.where(selectOne().from(employee).where(survey1.name.eq(employee.lastname)).exists());
    assertEquals(0, update.execute());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 17 with QEmployee

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

the class UpdateBase method update_with_subQuery_exists_Params.

@Test
public void update_with_subQuery_exists_Params() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    Param<Integer> param = new Param<Integer>(Integer.class, "param");
    SQLQuery<?> sq = query().from(employee).where(employee.id.eq(param));
    sq.set(param, -12478923);
    SQLUpdateClause update = update(survey1);
    update.set(survey1.name, "AA");
    update.where(sq.exists());
    assertEquals(0, update.execute());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) Param(com.querydsl.core.types.dsl.Param) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 18 with QEmployee

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

the class UpdateBase method update_with_subQuery_exists.

@Test
public void update_with_subQuery_exists() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLUpdateClause update = update(survey1);
    update.set(survey1.name, "AA");
    update.where(selectOne().from(employee).where(survey1.id.eq(employee.id)).exists());
    assertEquals(1, update.execute());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 19 with QEmployee

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

the class UpdateBase method update_with_subQuery_notExists.

@Test
public void update_with_subQuery_notExists() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLUpdateClause update = update(survey1);
    update.set(survey1.name, "AA");
    update.where(query().from(employee).where(survey1.id.eq(employee.id)).notExists());
    assertEquals(0, update.execute());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 20 with QEmployee

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

the class PaginationTest method test.

@Test
public void test() {
    List<SQLTemplates> list = Lists.newArrayList();
    list.add(new CUBRIDTemplates());
    list.add(new DerbyTemplates());
    list.add(new H2Templates());
    list.add(new HSQLDBTemplates());
    list.add(new MySQLTemplates());
    // inner query
    list.add(new OracleTemplates());
    list.add(new PostgreSQLTemplates());
    list.add(new SQLiteTemplates());
    list.add(new SQLServerTemplates());
    // inner query
    list.add(new SQLServer2005Templates());
    list.add(new SQLServer2012Templates());
    // qualify
    list.add(new TeradataTemplates());
    for (SQLTemplates templates : list) {
        QEmployee employee = QEmployee.employee;
        QueryMixin<?> query = new QueryMixin<Void>();
        query.from(employee);
        query.orderBy(employee.firstname.asc());
        query.setProjection(employee.id);
        System.out.println(templates.getClass().getSimpleName());
        System.out.println();
        // limit
        query.restrict(QueryModifiers.limit(10L));
        System.out.println("* limit");
        System.out.println(serialize(query.getMetadata(), templates));
        System.out.println();
        if (!templates.getClass().equals(SQLServerTemplates.class)) {
            // offset
            query.restrict(QueryModifiers.offset(10L));
            System.out.println("* offset");
            System.out.println(serialize(query.getMetadata(), templates));
            System.out.println();
            // limit and offset
            query.restrict(new QueryModifiers(10L, 10L));
            System.out.println("* limit and offset");
            System.out.println(serialize(query.getMetadata(), templates));
            System.out.println();
        }
    }
}
Also used : QueryModifiers(com.querydsl.core.QueryModifiers) QueryMixin(com.querydsl.core.support.QueryMixin) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Aggregations

QEmployee (com.querydsl.sql.domain.QEmployee)27 Test (org.junit.Test)27 QSurvey (com.querydsl.sql.domain.QSurvey)10 SQLDeleteClause (com.querydsl.sql.dml.SQLDeleteClause)6 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)4 SQLUpdateClause (com.querydsl.sql.dml.SQLUpdateClause)4 Tuple (com.querydsl.core.Tuple)3 QueryMetadata (com.querydsl.core.QueryMetadata)2 Param (com.querydsl.core.types.dsl.Param)2 Employee (com.querydsl.sql.domain.Employee)2 Connection (java.sql.Connection)2 QueryModifiers (com.querydsl.core.QueryModifiers)1 QueryMixin (com.querydsl.core.support.QueryMixin)1 IncludeIn (com.querydsl.core.testutil.IncludeIn)1 SubQueryExpression (com.querydsl.core.types.SubQueryExpression)1 Ignore (org.junit.Ignore)1