Could I query ‘case when’ sql statement to JPAContainer?
sql statement as below:
select issue,
sum(case when STATUS='NORMAL' THEN 1 ELSE 0 END) as NORMAL,
sum(case when STATUS='WARNING' THEN 1 ELSE 0 END) as WARNING,
sum(case when STATUS='CRITICAL' THEN 1 ELSE 0 END) as CRITICAL
from history_table
group by issue
I guess I need to follow “19.7. Querying with the Criteria API”. But I have no idea how to implement ‘case when’. Could someone give me the example?
And I dont understand what is the different between these two methods. I think usuablly I should ‘orderByWillBeAdded()’?
orderByWillBeAdded()
orderByWasAdded()
I am using JPAContainer for my project. I create two view without the problem. Now I want to create one more view, the data source is from the sql as my post. I think “19.7. Querying with the Criteria API” maybe could help, I will try. I am look for someone could give me hints. Thanks.
I believe the view to be a Table, why don’t you go with Generated Columns? instead of using case statements get the actual value as is from the DB and use Table generated columns to render the data according to your need using if statements.
I guess JPAContainer does not support to modify select part of query. I can not find any example from this forum and google. Maybe I should giveup JPAContainer.