java - SQL 'case when' in hibernate Criteria -
how can tranform following query hibernate criteria?
select pr_name, count(*) (select (case when serv.type=xyz serv.namea else serv.nameb end) pr_name db.serv serv serv.date null group pr_name;
i have got following handle rest (except case part)
currentsession.createcriteria(storeddata.class) .setprojection(projectionlist() .add(groupproperty("pr_name"), "pr_name") .add(rowcount(), "count")) .add(isnull("date")) .setresulttransformer(new prcounttransformer()) .list();
you can create property prname
in storeddata
, define "case" part pure sql using annotation @formula
.
Comments
Post a Comment