Problème de cast d'un Object en Long
Bonjour,
Je souhaiterais savoir caster un type de retour d'une requête avec JPQL ?
Ma méthode:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public List<Long> sommeClassesRep(Choix choix) {
Query q1xx = em.createQuery("SELECT SUM(h.nb1xx), SUM(h.nb2xx),SUM(h.nb3xx),SUM(h.nb4xx),SUM(h.nb5xx) FROM HttpEntity h WHERE h.host = :host and h.date_http BETWEEN to_date(:startDate,'dd/mm/yyyy HH24:mi:ss') AND to_date(:endDate,'dd/mm/yyyy HH24:mi:ss')");
q1xx.setParameter("host",choix.getHost() );
q1xx.setParameter("startDate", convert.convertDateTime(choix.getStartdate()) );
q1xx.setParameter("endDate", convert.convertDateTime(choix.getEndDate()));
List<BigDecimal[]> listSomme = new ArrayList<BigDecimal[]>();
listSomme = (List<BigDecimal[]>) q1xx.getResultList();
List<Long> listResultat = new ArrayList<Long>();
for (BigDecimal[] obj: listSomme ){
listResultat.add(( obj[0]).longValue());
listResultat.add(( obj[1]).longValue());
listResultat.add(( obj[2]).longValue());
listResultat.add(( obj[3]).longValue());
listResultat.add(( obj[4]).longValue());
}
return listResultat;
} |
Quelqu'un saurait-il m'indiquer comment convertir le résultat obtenu de cette requête, en une liste de long ?
Merci d'avance pour votre aide.