我按如下方式创建了一个类......
public class BeanA{
private String customerId;
private String cutomerName;
private Map<String, SubMarket> subMarkets = new HashMap<>();
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getCutomerName() {
return cutomerName;
}
public void setCutomerName(String cutomerName) {
this.cutomerName = cutomerName;
}
public Map<String, String> getSubMarkets() {
return subMarkets;
}
public void setSubMarkets(Map<String, String> subMarkets) {
this.subMarkets = subMarkets;
}
}
我也做了hibernate映射。
完全有效。
现在我想获得结果集,其中[Map]键=某个值和值=某个值...
我希望有一个hibernate查询来获取结果集。
答案 0 :(得分:0)
JPQL查询如下
SELECT a FROM BeanA a JOIN a.subMarkets s
WHERE KEY(s) = :some AND VALUE(s) = : someOther
假设Hibernate版本是固定HHH-5396的版本。
答案 1 :(得分:0)
您可以将数据加载为这样的地图:
Hibernate doc示例:
select
new map(
max(bodyWeight) as max,
min(bodyWeight) as min, count(*) as n
)
from Cat cat
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-select
答案 2 :(得分:0)
我最终得到了正确答案:
from [tableName]C where 'test' in indices(C.[mapName]) and 'Success' in elements(C.[mapName])