From 8e94a17a71ee9b7a385220374f9b6d93d3adf062 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Thu, 11 Jun 2020 10:41:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/app/service/CountServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/app/service/CountServiceImpl.java b/src/com/app/service/CountServiceImpl.java index 2f21d9e..ae5e61a 100644 --- a/src/com/app/service/CountServiceImpl.java +++ b/src/com/app/service/CountServiceImpl.java @@ -7,6 +7,7 @@ import org.hibernate.Session; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; +import org.hibernate.transform.Transformers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.HibernateTemplate; @@ -41,7 +42,7 @@ public class CountServiceImpl implements CountService{ public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query=session.createSQLQuery( "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(); } }); }