数据统计

master
pan 5 years ago
parent 257f09b1f9
commit 8e94a17a71
  1. 3
      src/com/app/service/CountServiceImpl.java

@ -7,6 +7,7 @@ import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projections; import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.orm.hibernate3.HibernateTemplate;
@ -41,7 +42,7 @@ public class CountServiceImpl implements CountService{
public Object doInHibernate(Session session) throws HibernateException, SQLException { public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query=session.createSQLQuery( Query query=session.createSQLQuery(
"select substring(created,1,10) as date,count(*) as count from "+c.getSimpleName()+" group by substring(created,1,10)"); "select substring(created,1,10) as date,count(*) as count from "+c.getSimpleName()+" group by substring(created,1,10)");
return query.list(); return query.setResultTransformer(Transformers.aliasToBean(Count.class)).list();
} }
}); });
} }

Loading…
Cancel
Save