Hibernate AliasToBeanResultTransformer传递内部类抛出错误

时间:2019-02-14 10:52:18

标签: java hibernate inner-classes

我使用AliasToBeanResultTransformer将SQL结果检索到自定义类中。

有时候我想以参数的形式传递给变压器内部类,但出现错误:

  

无法实例化结果类:com.myProject.reportsServices.PersonService $ PersonParamsForReoprt

当我将内部类转变为独立类时,一切正常! 有什么解决办法还是我必须将其拆分为独立的类?

示例:

public class PersonService {

    public ReportData GetPeopleReport(){
        org.hibernate.Query query = session.createSQLQuery(peopleQuery);
        query.setResultTransformer(
            new AliasToBeanResultTransformer(PersonParamsForReoprt.class)
        );
        List<PersonParamsForReoprt> result = query.list();

        //continue logic...
    }

    public class PersonParamsForReoprt{ 
        public PersonParamsForReoprt (){}
        //some fields with getters and setters...
    }
}

0 个答案:

没有答案