Merge pull request #1135 from querydsl/i1128

Add test case for CaseBuilder usage
This commit is contained in:
Ruben Dijkstra 2015-01-31 11:09:13 +01:00
commit 35f890b409

View File

@ -321,6 +321,19 @@ public abstract class AbstractJPATest {
.otherwise(4));
}
@Test
public void CaseBuilder() {
QCat cat2 = new QCat("cat2");
NumberExpression<Integer> casex = new CaseBuilder()
.when(cat.weight.isNull().and(cat.weight.isNull())).then(0)
.when(cat.weight.isNull()).then(cat2.weight)
.when(cat2.weight.isNull()).then(cat.weight)
.otherwise(cat.weight.add(cat2.weight));
query().from(cat, cat2).orderBy(casex.asc()).list(cat.id, cat2.id);
query().from(cat, cat2).orderBy(casex.desc()).list(cat.id, cat2.id);
}
@Test
public void Cast() {
List<Cat> cats = query().from(cat).list(cat);