use of com.querydsl.core.QueryModifiers in project querydsl by querydsl.
the class SQLServer2005Templates method serializeDelete.
@Override
public void serializeDelete(QueryMetadata metadata, RelationalPath<?> entity, SQLSerializer context) {
// limit
QueryModifiers mod = metadata.getModifiers();
if (mod.isRestricting()) {
metadata = metadata.clone();
metadata.addFlag(new QueryFlag(QueryFlag.Position.AFTER_SELECT, Expressions.template(Integer.class, topTemplate, mod.getLimit())));
}
context.serializeForDelete(metadata, entity);
if (!metadata.getFlags().isEmpty()) {
context.serialize(Position.END, metadata.getFlags());
}
}
use of com.querydsl.core.QueryModifiers 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();
}
}
}
use of com.querydsl.core.QueryModifiers in project querydsl by querydsl.
the class LuceneQueryTest method listDistinctResults.
@Test(expected = UnsupportedOperationException.class)
public void listDistinctResults() {
query.where(year.between(1800, 2000).or(title.eq("The Lord of the Rings")));
query.restrict(new QueryModifiers(1L, 1L));
query.orderBy(year.asc());
final QueryResults<Document> results = query.distinct().fetchResults();
assertFalse(results.isEmpty());
assertEquals("1954", results.getResults().get(0).get("year"));
assertEquals(1, results.getLimit());
assertEquals(1, results.getOffset());
assertEquals(4, results.getTotal());
}
use of com.querydsl.core.QueryModifiers in project querydsl by querydsl.
the class LuceneQueryTest method list_sorted_ascending_by_year_restrict_limit_2_offset_1.
@Test
public void list_sorted_ascending_by_year_restrict_limit_2_offset_1() {
query.where(year.between(1800, 2000));
query.restrict(new QueryModifiers(2L, 1L));
query.orderBy(year.asc());
final List<Document> documents = query.fetch();
assertFalse(documents.isEmpty());
assertEquals(2, documents.size());
assertEquals("1954", documents.get(0).get("year"));
assertEquals("1990", documents.get(1).get("year"));
}
use of com.querydsl.core.QueryModifiers in project querydsl by querydsl.
the class LuceneQueryTest method listDistinctResults.
@Test(expected = UnsupportedOperationException.class)
public void listDistinctResults() {
query.where(year.between(1800, 2000).or(title.eq("The Lord of the Rings")));
query.restrict(new QueryModifiers(1L, 1L));
query.orderBy(year.asc());
final QueryResults<Document> results = query.distinct().fetchResults();
assertFalse(results.isEmpty());
assertEquals("1954", results.getResults().get(0).get("year"));
assertEquals(1, results.getLimit());
assertEquals(1, results.getOffset());
assertEquals(4, results.getTotal());
}
Aggregations