Reputation: 314
Am looking for example on use case when condition in where clause on querydsl.
SELECT column1, column2 FROM viewWhatever WHERE CASE WHEN column1 == 'b' THEN account_location = ? WHEN column1 =='m' THEN location_area = ?
I just recently start using querydsl I can't figure out how to represent above query in querydsl case builder expression. I found examples for use in select clause but couldn't find much for use in where clause.
Upvotes: 0
Views: 2208
Reputation: 23226
Do you really need a CASE statement?
SELECT
column1, column2
FROM
viewWhatever
WHERE
(column1 == 'b' AND account_location = ?)
OR
(column1 =='m' AND location_area = ?)
Can obviously be easily represented in QueryDSL.
Upvotes: 1