错误描述:
hql语句:语句 String hql = "select new Customer(cust_id, cust_name) from Customer";
no appropriate constructor in class(没有可匹配的构造方法)
错误原因:
用hibernate框架时,映射时通过构造方法映射的,但是实体类中没有sql查询出来某字段的构造方法或直接没有构造方法
错误解决:
实体类中查看是否有sql中查询出字段的构造方法,加上此字段即可
public Customer(Long cust_id, String cust_name) {
super();
this.cust_id = cust_id;
this.cust_name = cust_name;
}