Search in sources :

Example 1 with QAnimal

use of com.querydsl.core.domain.QAnimal in project querydsl by querydsl.

the class JPQLSerializerTest method treated_path.

@Test
public void treated_path() {
    QAnimal animal = QAnimal.animal;
    JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
    QueryMetadata md = new DefaultQueryMetadata();
    md.addJoin(JoinType.DEFAULT, animal);
    md.addWhere(JPAExpressions.treat(animal, QCat.class).breed.eq(1));
    md.setProjection(animal);
    serializer.serialize(md, false, null);
    assertEquals("select animal\n" + "from Animal animal\n" + "where treat(animal as Cat).breed = ?1", 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) QAnimal(com.querydsl.core.domain.QAnimal) Test(org.junit.Test)

Aggregations

DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)1 QueryMetadata (com.querydsl.core.QueryMetadata)1 QAnimal (com.querydsl.core.domain.QAnimal)1 QCat (com.querydsl.core.domain.QCat)1 Test (org.junit.Test)1