【发布时间】:2013-01-31 12:53:28
【问题描述】:
我尝试了这个 hql 查询,但是当我在以下查询中使用 actProp[:key] = :value 时,它会引发 UnsupportedOperationException:
选择地图actionProperties中包含值对x,y或z,y的所有动作:
Query query = getSession().createQuery(
"select a from Action a " +
" join a.actionProperties actProp " +
" where (index(actProp) = :key " +
" and actProp[:key] = :value ) " +
" or (index(actProp) = :key2 " +
" and actProp[:key2] = :value ) ");
例外:
java.lang.UnsupportedOperationException
at org.hibernate.hql.ast.tree.IdentNode.resolveIndex(IdentNode.java:67)
在实体Action中:
@CollectionOfElements(fetch = FetchType.EAGER)
private Map<String, String> actionProperties;
我也尝试为此使用 Hibernate Criteria,但我认为这是不可能的。
有人知道用工作代码替换:actProp[:key] = :value 吗?
【问题讨论】:
标签: java hibernate jpa map hql