Reputation: 95
I have a query in hibernate that SUM two fields. But i don't know how to get the value in Object given List commandclient2.
This is the query
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();
}
});
I already try to use, but it gives Object
commandeclient2.get(0)
Upvotes: 1
Views: 83
Reputation: 19976
You have as a result
List<Object[]> commandeclient2
for(Object[] client : commandeclient2) {
client[0] //SUM(pafd)
client[1] //SUM(pmdm)
}
Upvotes: 1