sql语句如下String smsSql = "select new CupBill(appID,serviceCode,wayID,count(ID)) from CupSmsMT where sentDate>=? and sentDate<=? and receipt=0 group by appID,serviceCode,wayID";
构造方法如下:public CupBill(int appID, String serviceCode, int wayID,
int quantity) {
super();
this.appID = appID;
this.serviceCode = serviceCode;
this.wayID = wayID;
this.quantity = quantity;
}
我不知道是不是因为查询的名称和构造方法的名称不一样还是什么其他的问题,求解啊
------解决方案--------------------
如果用Hql来写的话:
直接
String smsSql = "from CupSmsMT where sentDate>=? and sentDate<=? and receipt=0 group by appID,serviceCode,wayID";
就可以了
然后 同Query query= session.createQuery(smsSql);
List<CupSmsMT>list = query.list();
for(CupSmsMT cup:list){
cup.getCupBill();//获得CupBill
}
这样就可以了
------解决方案--------------------
SQL语句可能有问题,还是按hql写法
String smsSql = "from CupSmsMT where sentDate>=? and sentDate<=? and receipt=0 group by appID,serviceCode,wayID";
取出的CupMmsMT数据赋给一些变量,把这些变量set到CupBill这个对象里