I'm using the Spring framework and the repositories, and in one of the interfaces of one of these repositories I have, for example, a method like this:
@Query("select extract(month from u.atributo1), coalesce(sum(u.atributo2), 0) from #{#entityName} u where extract(year from u.atributo1) = extract(year from current_date()) group by extract(month from u.atributo1)")
public List<HashMap<Integer, BigDecimal>> getDoisAtributos();
The Service that implements this method of the Repository interface on a role has been created and then the Controller instantiates that Service and calls the method responsible for retrieving the database values from the service method that then calls that function repository.
But I expected that in the attribute of type List
there would appear an Array with the attributes of type HashMap
but it appears the attributes being type Object
and when I run the attributes with a foreach for example or even with a for pops up an error saying that it was not possible to cast Object
to HashMap
.
Any solutions to this problem?