use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class ExpressionUtilsTest method in_subQuery.
@Test
public void in_subQuery() {
String s = ExpressionUtils.in(str, new SubQueryExpressionImpl<String>(String.class, new DefaultQueryMetadata())).toString();
assertTrue(s.startsWith("str in com.querydsl.core.DefaultQueryMetadata@c"));
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method openJPA_variables.
@Test
public void openJPA_variables() {
QCat cat = QCat.cat;
JPQLSerializer serializer = new JPQLSerializer(OpenJPATemplates.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 on cat_.mate.alive", serializer.toString());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method treat.
@SuppressWarnings("unchecked")
@Test
public void treat() {
QCat cat = QCat.cat;
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, cat);
md.addJoin(JoinType.JOIN, cat.mate.as((Path) QDomesticCat.domesticCat));
md.setProjection(QDomesticCat.domesticCat);
serializer.serialize(md, false, null);
assertEquals("select domesticCat\n" + "from Cat cat\n" + " inner join treat(cat.mate as DomesticCat) as domesticCat", serializer.toString());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method nullsLast.
@Test
public void nullsLast() {
QCat cat = QCat.cat;
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, cat);
md.addOrderBy(cat.name.asc().nullsLast());
serializer.serialize(md, false, null);
assertEquals("select cat\n" + "from Cat cat\n" + "order by cat.name asc nulls last", serializer.toString());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method count.
@Test
public void count() {
QCat cat = QCat.cat;
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, cat);
md.setProjection(cat.mate.countDistinct());
JPQLSerializer serializer1 = new JPQLSerializer(HQLTemplates.DEFAULT);
serializer1.serialize(md, true, null);
assertEquals("select count(count(distinct cat.mate))\n" + "from Cat cat", serializer1.toString());
JPQLSerializer serializer2 = new JPQLSerializer(HQLTemplates.DEFAULT);
serializer2.serialize(md, false, null);
assertEquals("select count(distinct cat.mate)\n" + "from Cat cat", serializer2.toString());
}
Aggregations