-2

我创建了一个类如下...

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;
   }
}

我也做了休眠映射。

它完全有效。

现在我想得到结果集,其中 [Map] key=some value and value= some value...

我希望通过休眠查询来获得该结果集。

4

3 回答 3

0

JPQL查询如下

SELECT a FROM BeanA a JOIN a.subMarkets s 
WHERE KEY(s) = :some AND VALUE(s) = : someOther

假设 Hibernate 版本是固定HHH-5396 的版本。

于 2013-05-27T19:28:37.407 回答
0

您可以像这样将数据加载为地图:

休眠文档示例:

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

于 2013-05-27T20:42:04.837 回答
0

我自己终于得到了正确的答案:

 from [tableName]C where 'test' in indices(C.[mapName]) and 'Success' in elements(C.[mapName])
于 2013-06-29T03:57:48.923 回答