使用案例
String queryStr = "select new Map(c.id as id,c.name as name,c.pycode as pycode,c.postcode as postcode,"
+ "c.areacode as areacode,c.sProvince.name as pname) from City c where c.sProvince.name=?";
说明:new map与new Map都行,无大小写之分.
用法出处
https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-select
(Hibernate Reference paragraph 14.6底部)
This is most useful when used together with select new map:
select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n ) from Cat cat
This query returns a Map from aliases to selected values.
本文介绍Hibernate HQL中使用newMap选择子来构造Map类型的查询结果的方法。通过具体示例展示了如何利用newMap将查询结果映射为Map集合,便于进一步的数据处理。
538

被折叠的 条评论
为什么被折叠?



