use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method delete_with_subQuery.
@Test
public void delete_with_subQuery() {
QCat parent = QCat.cat;
QCat child = new QCat("kitten");
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, child);
md.addWhere(child.id.eq(1).and(selectOne().from(parent).where(parent.id.eq(2), child.in(parent.kittens)).exists()));
serializer.serializeForDelete(md);
assertEquals("delete from Cat kitten\n" + "where kitten.id = ?1 and exists (select 1\n" + "from Cat cat\nwhere cat.id = ?2 and kitten member of cat.kittens)", serializer.toString());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method nullsFirst.
@Test
public void nullsFirst() {
QCat cat = QCat.cat;
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, cat);
md.addOrderBy(cat.name.asc().nullsFirst());
serializer.serialize(md, false, null);
assertEquals("select cat\n" + "from Cat cat\n" + "order by cat.name asc nulls first", serializer.toString());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class NativeSQLSerializerTest method in.
@Test
public void in() {
Configuration conf = new Configuration(new MySQLTemplates());
NativeSQLSerializer serializer = new NativeSQLSerializer(conf, true);
DefaultQueryMetadata md = new DefaultQueryMetadata();
SAnimal cat = SAnimal.animal_;
md.addJoin(JoinType.DEFAULT, cat);
md.addWhere(cat.name.in("X", "Y"));
md.setProjection(cat.id);
serializer.serialize(md, false);
assertEquals("select animal_.id\n" + "from animal_ animal_\n" + "where animal_.name in (?1, ?2)", serializer.toString());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class QueryPerformanceTest method serialization.
@Test
public void serialization() throws Exception {
QCompanies companies = QCompanies.companies;
final QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, companies);
md.addWhere(companies.id.eq(1L));
md.setProjection(companies.name);
Runner.run("ser1", new Benchmark() {
@Override
public void run(int times) throws Exception {
for (int i = 0; i < times; i++) {
SQLSerializer serializer = new SQLSerializer(conf);
serializer.serialize(md, false);
serializer.getConstants();
serializer.getConstantPaths();
assertNotNull(serializer.toString());
}
}
});
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class SQLListenersTest method notifyQuery_parent.
@Test
public void notifyQuery_parent() {
SQLListener listener = createMock(SQLListener.class);
SQLListeners listeners = new SQLListeners(listener);
QueryMetadata md = new DefaultQueryMetadata();
listener.notifyQuery(md);
replay(listener);
listeners.notifyQuery(md);
verify(listener);
}
Aggregations