Search in sources :

Example 11 with DefaultQueryMetadata

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"));
}
Also used : DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) Test(org.junit.Test)

Example 12 with DefaultQueryMetadata

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());
}
Also used : QCat(com.querydsl.core.domain.QCat) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) Test(org.junit.Test)

Example 13 with DefaultQueryMetadata

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());
}
Also used : QCat(com.querydsl.core.domain.QCat) Path(com.querydsl.core.types.Path) NumberPath(com.querydsl.core.types.dsl.NumberPath) EntityPath(com.querydsl.core.types.EntityPath) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) Test(org.junit.Test)

Example 14 with DefaultQueryMetadata

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());
}
Also used : QCat(com.querydsl.core.domain.QCat) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) Test(org.junit.Test)

Example 15 with DefaultQueryMetadata

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());
}
Also used : QCat(com.querydsl.core.domain.QCat) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) Test(org.junit.Test)

Aggregations

DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)25 Test (org.junit.Test)24 QueryMetadata (com.querydsl.core.QueryMetadata)19 QCat (com.querydsl.core.domain.QCat)7 StringPath (com.querydsl.core.types.dsl.StringPath)6 LuceneSerializer (com.querydsl.lucene5.LuceneSerializer)2 GroupExpression (com.querydsl.core.group.GroupExpression)1 Benchmark (com.querydsl.core.testutil.Benchmark)1 EntityPath (com.querydsl.core.types.EntityPath)1 Path (com.querydsl.core.types.Path)1 EntityPathBase (com.querydsl.core.types.dsl.EntityPathBase)1 NumberPath (com.querydsl.core.types.dsl.NumberPath)1 Location (com.querydsl.jpa.domain.Location)1 QEmployee (com.querydsl.jpa.domain.QEmployee)1 SAnimal (com.querydsl.jpa.domain.sql.SAnimal)1 PhraseElement (com.querydsl.lucene5.PhraseElement)1 TermElement (com.querydsl.lucene5.TermElement)1 Configuration (com.querydsl.sql.Configuration)1 MySQLTemplates (com.querydsl.sql.MySQLTemplates)1 Reflections (org.reflections.Reflections)1