1

I store in database data as | RAPORT_DAY | FIELD_VALUE | USER_ID. All works good if I specify user_id, I'm getting one record for one day. But if I dont specify user_id I'm getting a lot of records for same day. Is it possible to sum field_value for each day by criteria ?

    if (userId != null) {
        criteria.add(Restrictions.eq("user.id", userId));
    }
    criteria.add(Restrictions.ge("raportDay", dateFrom));
    criteria.add(Restrictions.le("raportDay", dateTo));
    criteria.setProjection(Projections.projectionList()
            .add(Projections.property("raportDay"))
            .add(Projections.property(field)));
kxyz
  • 802
  • 1
  • 9
  • 32
  • sorry but what is problem in that? Restrictions means where clause so if you don't specify user_id then table may be having lot of records for the same day. – Amogh Nov 21 '14 at 10:36
  • Yes it is: http://www.tutorialspoint.com/hibernate/hibernate_criteria_queries.htm – Ean V Nov 21 '14 at 12:27

0 Answers0