Dodekane
unread,Mar 1, 2011, 3:48:10 AM3/1/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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