且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从hibernate查询中获取java.util.Map?

更新时间:2022-10-20 11:34:50

See Hibernate Documentation - 15.6. The select clause:

You can assign aliases to selected expressions using as:

select max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n
from Cat cat

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.