I have a pretty simple case statement to write to querydsl:
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"))
The problem is that this expression is 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 putting goe and lt expressions inside the when clause?
BTW, directly specifying numbers does not seem to work with expressions. Must use Expressions.numberTemplate
source
share