我想从hibernate中的不同表中获取不同的列。 我的疑问是:
@NamedQuery(name="findAllfundSalesCreditCalc",query=" select distinct SF.subFundName, SF.id, case when FCM.subFundId is null "
+" then 'Not yet added' else 'Already exists' end as ExistsOrNot,CCM.calculationMethodName,"
+" FCM.effectiveFromDate, FCM.effectiveToDate,FCM.paymentFrequencyId,"
+" FCM.firstPaymentDate from FundSalesCreditCalcMethod FCM ,SubFund SF , Class C ,"
+" SC_Class SCC, SalesCreditCalcMethod CCM where SF.id = FCM.subFundId and "
+" CCM.id = FCM.salesCreditCalcMethodId and "
+" C.id = SF.id and "
+" SCC.classId = C.id")
我正在检索列表中的数据。
List<FundSalesCreditCalcMethod> fundSalesCreditCalc = getFundSalesCreditCalcMethodDao().getFundSalesCreditCalc();
public List<FundSalesCreditCalcMethod> getFundSalesCreditCalc() {
return this.entityManager.createNamedQuery("findAllfundSalesCreditCalc").getResultList();
}
public List<FundSalesCreditCalcMethodDTO> getFundSalesCreditCalculation() {
/* List<Object> fundSalesCreditCalc = getFundSalesCreditCalcMethodDao().getFundSalesCreditCalc();*/
List<FundSalesCreditCalcMethod> fundSalesCreditCalc = getFundSalesCreditCalcMethodDao().getFundSalesCreditCalc();
List<FundSalesCreditCalcMethodDTO> fundSalesCreditCalcMethodDtos = new ArrayList<FundSalesCreditCalcMethodDTO>();
for(FundSalesCreditCalcMethod fundSalesCredit: fundSalesCreditCalc) {
fundSalesCreditCalcMethodDtos.add(DTOCreator.createfundSalesCreditCalcDTO(fundSalesCredit));
}
return fundSalesCreditCalcMethodDtos;
}
这是错误:java.lang.classcastexception
。