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

前端 未结 2 1015
灰色年华
灰色年华 2020-12-01 11:11

I am developing an application in struts 2 and hibernate 3.

I have 3 tables

  1. Inspection
  2. InspectionMission
  3. Timeline

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 11:54

    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".

提交回复
热议问题