java 报no appropriate constructor解决方法

记一次使用hibernate操作数据库出现的错误

hql语句:语句 String hql = "select new Customer(cust_id, cust_name) from Customer";

目的:查询customer表中cust_id和cust_name两列数据并把它封装到Customer对象中;

错误原因:实体没有提供空参数构造方法和对应有参构造方法

解决办法:空参构造方法就不多说了,说说有参有构造方法,例如我上面是封装cust_id和cust_name,就需要提供下面的有参构造方法,其他以此类推

-------------------------------------------------------

public Customer(Long cust_id, String cust_name) {

super();

this.cust_id = cust_id;

this.cust_name = cust_name;

}

--------------------------------------------------



猜你喜欢

转载自blog.csdn.net/weixin_39286810/article/details/80726572
今日推荐