我有一个动态查询,它是根据传递给函数的一些数据生成的。因此,我实际上不知道结果中有多少列。 (该查询是Oracle 11G的一个pivot)。
我知道所有生成的列都将是数字项,有一个固定列始终是字符串。
我怎样才能得到map<String, List<Double>>
来自 hibernate 映射?
最佳答案
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-select
只需在 HQL 中创建选择并获取 map 列表。
举个例子:
select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n ) from Cat cat
使用原生查询教程: http://www.flexjunk.com/2008/03/07/native-sql-in-hibernate/
关于java - Hibernate 映射与动态查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20291178/