sum with group by

6 views
Skip to first unread message

Dodekane

unread,
Mar 1, 2011, 3:48:10 AM3/1/11
to Criteria4JPA
Hi,

I'm using Criteria4JPA for few weeks. Big thanks for your jobs. It
really help to make clear code.

I'm currently experiencing trouble making the aggregate fonction.

This is this JPA equivalant.

Query q = em.createQuery("SELECT l.category,l.component, SUM(l.value)
FROM Logger l WHERE l.level = 0 GROUP BY l.category,l.component");

I started with :
Criteria c = CriteriaUtils.createCriteria(em, Logger.class);
c.setProjection(Projections.projectionList()
.add(Projections.property("category"))
.add(Projections.property("component"))
.add(Projections.sum("value"))
);

But it seems i have trouble with the group by clause which is missing
and for which i can't found how to code it with the api.

The "One Minute Tutorial" is really helpfull, maybe some examples on
aggregate function could helps.

Regards and Thanks
Dodekane

Christian Kaltepoth

unread,
Mar 1, 2011, 10:09:46 AM3/1/11
to criter...@googlegroups.com, Dodekane
Hey Dodekane,

Unfortunately "GROUP BY" expressions are not implemented yet.

Could you perhaps open an issue for this? This way you will be
informed as soon as there is a version which supports this new
feature.

https://github.com/chkal/criteria4jpa/issues

Thank you for your feedback

Christian

2011/3/1 Dodekane <dode...@gmail.com>:

--
Christian Kaltepoth
Blog: http://chkal.blogspot.com/
Twitter: http://twitter.com/chkal

Reply all
Reply to author
Forward
0 new messages