I have a fairly straight forward case statement to write in querydsl:
case when column >= 1 and column < 31 then 1 else 0 end
I tried the following approach:
table.column.goe(Expressions.numberTemplate(Long.class,"1")).and(table.column.lt(Expressions.numberTemplate(Long.class, "31"))).when(Expressions.booleanTemplate("true")).then(Expressions.numberTemplate(Long.class, "1")).otherwise(Expressions.numberTemplate(Long.class, "0"))
Trouble is, this expression is being interpreted as:
select sum(case when table.column >= 1 and table.column < 31 = true then 1 else 0 end)
Is there a way to avoid specifying the when clause or to put the goe and lt expressions inside the when clause?
BTW, Directly specifying numbers doesnt seem to work in case expressions. Need to use Expressions.numberTemplate