diff --git a/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java b/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java index 68aedaf2c..628c3c956 100644 --- a/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java +++ b/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java @@ -321,6 +321,19 @@ public abstract class AbstractJPATest { .otherwise(4)); } + @Test + public void CaseBuilder() { + QCat cat2 = new QCat("cat2"); + NumberExpression 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 cats = query().from(cat).list(cat);