You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Jörg Knoche <kn...@MPA-Garching.MPG.DE> on 2011/09/19 11:03:02 UTC
Querying for multiple key/value pairs within a map
Hi,
I have a problem when querying for key/value of a map, where I
understood the problem and also already found a solution, but the
solution is not usable for me.
I have an object which contains a map with metadata and I want to query
now for these objects which have a specific set (key/value) of metadata.
I know that I have to specify the following query:
SELECT x from InitObject x JOIN x.metaDataset y WHERE KEY(y)='str' AND
VALUE(y)='str2'
This works for exactly one key/value pair, but I need to query for
several of these pairs. So my first try was to add another
AND KEY(y)='str3' AND VALUE(y)='str4'
which didn't return any result (which I can understand now).
After rewriting the query to the following:
SELECT x from InitObject x JOIN x.metaDataset y JOIN x.metaDataset z
WHERE KEY(y)='str' AND VALUE(y)='str2' AND KEY(z)='str3' AND VALUE(z)='str4'
it worked as expected. But I don't like the idea of adding additional
JOINs for every pair I want to query for, so my question is, if there is
another way to do these queries since the number of pairs to query for
can reach up to about 50.
Cheers and thanks in advance,
Joerg.