简体   繁体   English

带动态查询的 Hibernate 映射

[英]Hibernate mapping with dynamic query

I have a dynamic query that is being generated in base of some data passed to a function.我有一个动态查询,它是根据传递给函数的一些数据生成的。 For this reason, I don't actually know how many columns I will have in my result.出于这个原因,我实际上不知道我的结果中有多少列。 (The query is a pivot of Oracle 11G). (查询是 Oracle 11G 的一个枢纽)。 I know that all the generated columns will be numeric items, there's a fixed column that will be always a string.我知道所有生成的列都是数字项,有一个固定列将始终是一个字符串。 How can i get a map<String, List<Double>> from hibernate mapping?如何从休眠映射中获取map<String, List<Double>>

http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-select http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-select

Just create select in HQL and get list of map.只需在 HQL 中创建选择并获取地图列表。

As a example:例如:

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

Using native query tutorial: http://www.flexjunk.com/2008/03/07/native-sql-in-hibernate/使用原生查询教程: http : //www.flexjunk.com/2008/03/07/native-sql-in-hibernate/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM