简体   繁体   English

JPQL(HQL)在查询中使用Map类型的参数

[英]JPQL (HQL) use parameter of type Map in query

I have a HashMap<String, Float> paramMap 我有一个HashMap<String, Float> paramMap

Where the key is the id of entity Invoice and the value is some calculation. 其中键是实体发票的ID,值是一些计算。

JPA allowes this map to be set as a parameter with name "paramMap". JPA允许将此地图设置为名称为“ paramMap”的参数。

Is it possible to use the map in the jpql(hql) in the following manner? 是否可以通过以下方式在jpql(hql)中使用地图? (the query is simplified for the example but it captures the esence of my inquery) (此示例简化了查询,但它捕获了我的查询的本质)

SELECT Invoice.id as key, :paramMap[Invoice.id] as value from Invoice Invoice 选择Invoice.id作为键,选择:paramMap [Invoice.id]作为Invoice发票中的值

Is it possible to use a map in JPQL (HQL) in the following manner? 是否可以通过以下方式在JPQL(HQL)中使用地图?

No, it's not possible. 不,不可能。

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

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