首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

hibernate错误:Unable to locate appropriate constructor on class

2012-02-28 
hibernate异常:Unable to locate appropriate constructor on classsql语句如下String smsSql select n

hibernate异常:Unable to locate appropriate constructor on class
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这个对象里

热点排行