Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 嵌套异常为org.hibernate.HibernateException:无法实例化resultclass_Spring_Spring Boot - Fatal编程技术网

Spring 嵌套异常为org.hibernate.HibernateException:无法实例化resultclass

Spring 嵌套异常为org.hibernate.HibernateException:无法实例化resultclass,spring,spring-boot,Spring,Spring Boot,怎么了 public List < ReportDTO> listProductAll() { String sql = "select " + "ip.product_name as productName, " + "ip.base_price as basePrice, " + "iu.username as username " + "from t

怎么了

public List < ReportDTO> listProductAll() {
    String sql 
            = "select "
            + "ip.product_name as productName, "
            + "ip.base_price as basePrice, "
            + "iu.username as username "
            + "from tb_buy a  "
            + "left join in_product ip on a.id_product = ip.product_id "
            + "left join im_users iu on a.id_user = iu.user_id ";
    Query q = identifyServer.getCurrentSession().createSQLQuery(sql)
            .addScalar("productName")
            .addScalar("basePrice")
            .addScalar("username")
            .setResultTransformer(Transformers.aliasToBean(ReportDTO.class));
    return q.list();
}

public class ReportDTO {

    private String productName;
    private Double basePrice;
    private String username;

    public ReportDTO(String productName, Double basePrice, String username) {
        this.productName = productName;
        this.basePrice = basePrice;
        this.username = username;
    }
// getter setter
public ListlistProductAll(){
字符串sql
=“选择”
+ip.product\u名称作为产品名称
+“ip.基价作为基价,”
+“iu.username作为用户名”
+“从tb_购买”
+“左加入a.id上的产品ip\u product=ip.product\u id”
+“在a.id\u user=iu.user\u id上左加入im\u用户iu”;
Query q=identifyServer.getCurrentSession().createSQLQuery(sql)
.addScalar(“产品名称”)
.addScalar(“基准价格”)
.addScalar(“用户名”)
.setResultTransformer(Transformers.aliasToBean(ReportDTO.class));
返回q.list();
}
公共类报告{
私有字符串产品名称;
私人双基价;
私有字符串用户名;
public ReportDTO(字符串产品名、双基价格、字符串用户名){
this.productName=productName;
this.basePrice=基准价格;
this.username=用户名;
}
//吸气剂设定器
org.springframework.orm.jpa.JpaSystemException:无法实例化resultclass:ReportDTO;嵌套异常为org.hibernate.hibernateeexception:无法实例化resultclass:ReportDTO

解决
public ReportDTO(){}

Hibernate要求所有实体都具有默认的无参数构造函数。
如果您的实体类没有它,或者它不是公共的,您将得到这个异常