use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method join_with.
@Test
public void join_with() {
QCat cat = QCat.cat;
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, cat);
md.addJoin(JoinType.INNERJOIN, cat.mate);
md.addJoinCondition(cat.mate.alive);
serializer.serialize(md, false, null);
assertEquals("select cat\nfrom Cat cat\n inner join cat.mate with cat.mate.alive", serializer.toString());
}
use of com.querydsl.core.DefaultQueryMetadata 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());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class PhraseElementTest method test.
@Test
public void test() {
StringPath title = Expressions.stringPath("title");
LuceneSerializer serializer = new LuceneSerializer(false, false);
QueryMetadata metadata = new DefaultQueryMetadata();
assertEquals("title:Hello World", serializer.toQuery(title.eq("Hello World"), metadata).toString());
assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class QueryPerformanceTest method querydsl14.
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querydsl14() throws Exception {
try (Connection conn = Connections.getH2()) {
QCompanies companies = QCompanies.companies;
SQLQuery<?> query = new SQLQuery<Void>(conn, conf, new DefaultQueryMetadata());
query.from(companies).where(companies.id.eq((long) ThreadLocalRandom.current().nextLong())).select(companies.name).fetch();
}
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class SQLListenersTest method notifyQuery_detailedListener_contexSetting.
@Test
public void notifyQuery_detailedListener_contexSetting() {
SQLListenerContext sqlListenerContext = new SQLListenerContextImpl(new DefaultQueryMetadata());
SQLDetailedListener listenerParent = new AssertingDetailedListener("keyParent", "valueParent");
SQLDetailedListener listener1 = new AssertingDetailedListener("key1", "value1");
SQLDetailedListener listener2 = new AssertingDetailedListener("key1", "value1");
SQLListeners listeners = new SQLListeners(listenerParent);
listeners.add(listener1);
listeners.add(listener2);
listeners.start(sqlListenerContext);
listeners.preRender(sqlListenerContext);
listeners.rendered(sqlListenerContext);
listeners.prePrepare(sqlListenerContext);
listeners.prepared(sqlListenerContext);
listeners.preExecute(sqlListenerContext);
listeners.preExecute(sqlListenerContext);
}
Aggregations