Pojo类的休眠映射问题

时间:2019-02-13 14:46:05

标签: java hibernate

在休眠状态下使用pojo类映射查询时遇到问题。就我而言,我正在运行查询,并尝试将查询结果设置为除实体之外的某些Java类。我的查询在列名中有别名,而别名未在我的实体中定义(因为别名是动态的)。当我运行代码时,它会引发异常

异常

( 12002 ) Internal Service Error Exception Message : Data Access Exception occurred [Unknown entity:
com.ykb.hmn.cms.commission.datamodel.CmsMonthlyPaymentDetail

Query.hbm.xml

<sql-query name="getCommissionBetweenDatesWithStat">
        <return class="com.ykb.hmn.cms.commission.datamodel.CmsMonthlyPaymentDetail"/>
            <![CDATA[ 
                    SELECT COMDT_COM_CCY CURRENCY, SUM(COMDT_COM_AMT1) PAYMENT
                    FROM COMDT 
                    WHERE COMDT_COM_REFNO = :refNo
                    AND COMDT_COM_RDN BETWEEN :startRdn AND :endRdn 
                    AND COMDT_COM_STAT = :stat
                    GROUP BY COMDT_COM_STAT, COMDT_COM_REFNO, COMDT_COM_CCY  
                    ORDER BY COMDT_COM_REFNO
            ]]>
        </sql-query>

Pojo课堂-我想映射到该课堂

public class CmsMonthlyPaymentDetail implements Serializable{

    private double payment;
    private String currency;

    public double getPayment() {
        return payment;
    }
    public void setPayment(double payment) {
        this.payment = payment;
    }
    public String getCurrency() {
        return currency;
    }
    public void setCurrency(String currency) {
        this.currency = currency;
    }
}

服务

@Override
    public List<ResponseCommissionTransactionDetail> getCommissionMonthlyPaymentDetail(RequestCommissionTransactionDetail request) throws HmnServiceException {
        Integer startRdn = DateUtil.dateToRelDay(request.getStartDate());
        Integer endRdn = DateUtil.dateToRelDay(request.getEndDate());
        final Character requestedStat = 'O';

        //Crashes in this line
        List<CmsMonthlyPaymentDetail> queryResult = DAOLocator.getComDetailDAO().getCommissionBetweenDatesWithStat(request.getCommissionRefNo(), startRdn, endRdn, requestedStat);

        List<ResponseCommissionTransactionDetail> response = null;

        if (queryResult != null) {
            response = new ArrayList<ResponseCommissionTransactionDetail>();

            for (Iterator<CmsMonthlyPaymentDetail> iterator = queryResult.iterator(); iterator.hasNext();) {
                CmsMonthlyPaymentDetail monthlyPaymentDetail = iterator.next();

                ResponseCommissionTransactionDetail commissionDetail = new ResponseCommissionTransactionDetail();

                commissionDetail.setRefNo(request.getCommissionRefNo());
                commissionDetail.setAmount(monthlyPaymentDetail.getPayment());
                commissionDetail.setCurrency(monthlyPaymentDetail.getCurrency());

                response.add(commissionDetail);
            }
        }


        return response;
    }

非常感谢

0 个答案:

没有答案