代码如下:Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select goodsId,sum(goodsTotal) from Goodsinfo where outbound_id in (select outboundId from Robound where state='"
+ state + "') and createTime between '"+ time1+ "' and '"+ time2+ "'group by goodsId");我想返回goodsId和sum(goodsTotal),该怎么写啊?
+ state + "') and createTime between '"+ time1+ "' and '"+ time2+ "'group by goodsId");我想返回goodsId和sum(goodsTotal),该怎么写啊?
然后List l1=query.list();
此时 li是一个list l1.get(i)也返回一个list
思路是这样,可能也有别的好方法,暂时只知道着一个
代码如下:
public void testTest()
{
Session s=HibernateSessionFactory.getSession();
s.beginTransaction();
Query q=s.createQuery("select new list(u.id,u.name) from User u ");
List l=q.list();
for(int i=0;i<l.size();i++)
{
List l2=(List) l.get(i);
System.out.println(l2.get(0));//输出u.id
System.out.println(l2.get(1));//输出u.name
}
s.getTransaction().commit();
s.close();
}