dimanche 3 mai 2015

Criteria Logical expression in Group by clause

im trying to create a Criteria query that uses a logical expression in a group by clause.

The working SQL statement is something like this:

SELECT * FROM T_USER GROUP BY foreignKeyId=1

Yes this example makes not much sense, but the original query is much more complicated and I only want to know how it is possible to realise that "GROUP BY foreignKeyId=1" part in Hibernate Criteria.

Full Query:

Select *,SUM(vot.rate)as total from T_TAG as tag left outer join T_VOTING as vot on tag.tagid=vot.tagid group by vot.tagid,vot.userid=1 order by (vot.userid=1 and vot.rate>0)desc,(vot.userid<>1)desc,(vot.userid=1 and vot.rate<0)desc,total desc

Thanks for helping.

Aucun commentaire:

Enregistrer un commentaire