java - Hibernate criteria group by date without time -


this code give me list of 2 items datetime , count. need group date without time.

can give me clue how it? thanks!

    criteria criteria = getsession().createcriteria(parcel.class);      projectionlist projectionlist = projections.projectionlist();           projectionlist.add(projections.groupproperty("datecreated"));         projectionlist.add(projections.rowcount());      criteria.setprojection(projectionlist);       list<object[]> results = criteria.list(); 

result:

2013-04-27 11:08:00.0 | 32

2013-04-27 11:10:00.0 | 5

2013-04-28 15:03:27.0 | 12

i need:

2013-04-27 | 37

2013-04-28 | 12

you may find projections#sqlgroupprojection method useful. allows employ sql function date() extracts date form datetime column. basically, instead of calling

projectionlist.add(projections.groupproperty("datecreated")); 

use

projectionlist.add(projections.sqlgroupprojection("date(datecreated) createddate", "createddate", new string[] { "createddate" }, new type[] { standardbasictypes.date })); 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -