我在hibernate中有一个查询SUM两个字段。但我不知道如何获取Object given commandclient2中的值。
这是查询
List commandeclient2 = getHibernateTemplate().execute(new HibernateCallback<List>() {
@Override
public List doInHibernate(Session session) throws HibernateException {
Query query = session.createQuery(
"SELECT SUM(pafd) as pafds, SUM(pmdm) as pmdms FROM Commandeclient c WHERE c.modepayement IS NOT NULL AND c.montantpaye IS NOT NULL"
);
return query.list();
}
});
我已经尝试使用,但它提供了对象
commandeclient2.get(0)
答案 0 :(得分:1)
你有结果
List<Object[]> commandeclient2
for(Object[] client : commandeclient2) {
client[0] //SUM(pafd)
client[1] //SUM(pmdm)
}