Hi
I would know if this type of query is supported By JPA:
select sum(nb1), sum(nb2), sum(nb3) from table
If yes I have this methode that return a list of Long:
public List<Long> sommeClassesRep(Choix choix) { Query listClassRepHost = 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')"); listClassRepHost.setParameter("host",choix.getHost() ); listClassRepHost.setParameter("startDate", convert.convertDateTime(choix.getStartdate()) ); listClassRepHost.setParameter("endDate", convert.convertDateTime(choix.getEndDate())); List<BigDecimal[]> listRes = new ArrayList<BigDecimal[]>(); listRes = (List<BigDecimal[]>) listClassRepHost.getResultList(); List<Long> listSommeLong = new ArrayList<Long>(); for (BigDecimal[] bigDecimals : listRes) { for (int i = 0; i < bigDecimals.length; i++) { listSommeLong.add(bigDecimals[i].longValue()); } } return listSommeLong; }
When i debug i have a sever error that Object can't cast to Big decimal
and my query always retuen a list of Long like this : [120,0,314,464646,0]
can you help me please
Thankss