mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Merge pull request #1135 from querydsl/i1128
Add test case for CaseBuilder usage
This commit is contained in:
commit
35f890b409
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user