Search in sources :

Example 1 with QueryMixin

use of com.querydsl.core.support.QueryMixin 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

QueryModifiers (com.querydsl.core.QueryModifiers)1 QueryMixin (com.querydsl.core.support.QueryMixin)1 QEmployee (com.querydsl.sql.domain.QEmployee)1 Test (org.junit.Test)1