How to fetch hibernate query result as associative array of list or hashmap

You have to use the “new map” syntax (Hibernate Reference paragraph 14.6)

select new map(count(i.inspectionId) as tot_inspections, t.year as year, t.quarter as quarter) from ...

The rest of the query is the same. This will return a list of maps, where the key is the alias of the “column”.

Leave a Comment