使用HQL查询地图的值 [英] Using HQL to query on a Map's Values
问题描述
myClass.mapElem< Object,Object>
),如下所示: Key Val
AX
BY
CX
我想编写可以查询值的HQL,以便我可以回收myClass的所有实例,其中mapElem的值为'X'(其中'X'是一个完全填充的对象 - 我只是不想通过每个元素,并说x.e1 = mapElem.e1和x.e2 = ...等)。我知道我可以通过使用在这里做到这一点在索引(myClass.mapElem)
中,我只需要相应的语句来查询值!
提前感谢...
ETA:不确定语法是否有所作为,但我实际查询的方式如下:
select myClass.something from myClass mc join myClass.mapElem me where ...
在我特定的情况下,我最终不得不使用SQL查询。不理想,但它的工作。
Let's say I have a map (call it myClass.mapElem<Object, Object>
) like so:
Key Val
A X
B Y
C X
I want to write HQL that can query the Values such that I can get back all instances of myClass where mapElem's value is 'X' (where 'X' is a fully populated object-- I just don't want to go through each element and say x.e1 = mapElem.e1 and x.e2=... etc). I know I can do this for the keys by using where ? in index(myClass.mapElem)
, I just need the corresponding statement for querying the values!
Thanks in advance...
ETA: Not sure if the syntax makes a difference, but the way I am actually querying this is like so:
select myClass.something from myClass mc join myClass.mapElem me where...
In my particular case, I ended up having to use an SQL query. Not ideal, but it worked.
这篇关于使用HQL查询地图的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!