在休眠状态下使用pojo类映射查询时遇到问题。就我而言,我正在运行查询,并尝试将查询结果设置为除实体之外的某些Java类。我的查询在列名中有别名,而别名未在我的实体中定义(因为别名是动态的)。当我运行代码时,它会引发异常
( 12002 ) Internal Service Error Exception Message : Data Access Exception occurred [Unknown entity:
com.ykb.hmn.cms.commission.datamodel.CmsMonthlyPaymentDetail
<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>
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;
}
非常感谢