public PaymentDTO getPayment(String compindex){
HBSession session = HBUtil.getHBSession();
PaymentDTO paymentDTO=new PaymentDTO();
try { String hql = "select sum(a.payradix * b.personproportion) personpay,sum(a.payradix * b.companyproportion) companypay from InsurantInfo a,InsuranceType b where a.instpcode=b.instpcode ";
Query query = session.createQuery(hql); List list = query.list();
Iterator ite = list.iterator();
while (ite.hasNext()) {
Object[] object = (Object[]) ite.next();
paymentDTO.setPersonpay((String)object[0]);
paymentDTO.setCompanypay((String)object[1]);
}
} catch (HibernateException e) {
e.printStackTrace();
}
return paymentDTO;
}执行到Query query = session.createQuery(hql);就报错,很简单的HQL啊,难道是sum在HQL不是这么用的?
错误消息:java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
org.hibernate.QueryException: , expected in SELECT [select sum(a.payradix * b.personproportion) personpay,sum(a.payradix * b.companyproportion) companypay from com.insigma.sionline.local.comm.entity.InsurantInfo a,com.insigma.sionline.local.comm.entity.InsuranceType b where a.instpcode=b.instpcode ]
HBSession session = HBUtil.getHBSession();
PaymentDTO paymentDTO=new PaymentDTO();
try { String hql = "select sum(a.payradix * b.personproportion) personpay,sum(a.payradix * b.companyproportion) companypay from InsurantInfo a,InsuranceType b where a.instpcode=b.instpcode ";
Query query = session.createQuery(hql); List list = query.list();
Iterator ite = list.iterator();
while (ite.hasNext()) {
Object[] object = (Object[]) ite.next();
paymentDTO.setPersonpay((String)object[0]);
paymentDTO.setCompanypay((String)object[1]);
}
} catch (HibernateException e) {
e.printStackTrace();
}
return paymentDTO;
}执行到Query query = session.createQuery(hql);就报错,很简单的HQL啊,难道是sum在HQL不是这么用的?
错误消息:java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
org.hibernate.QueryException: , expected in SELECT [select sum(a.payradix * b.personproportion) personpay,sum(a.payradix * b.companyproportion) companypay from com.insigma.sionline.local.comm.entity.InsurantInfo a,com.insigma.sionline.local.comm.entity.InsuranceType b where a.instpcode=b.instpcode ]
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货