SQL/HQL Query: find object that has a list of objects that matchs some parameters
<p>I have these entities:</p>
<p><a href="https://i.stack.imgur.com/M1lU9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M1lU9.png" alt="ER Diagram" /></a></p>

<p>Suppose I receive this <code>map&lt;String,String&gt;</code>:</p>
<blockquote>
<p>&quot;gender&quot;: &quot;male&quot;</p>
<p>&quot;age&quot;: &quot;30&quot;</p>
</blockquote>
<p>I need to find the campaigns that have a <strong>TargetGroup that contains all these key/values from the map</strong>.
Example:</p>
<pre><code>Map&lt;String,String&gt; keyValueParameters = new HashMap&lt;String,String&gt;();
keyValueParameters.put(&quot;gender&quot;,&quot;male&quot;);
keyValueParameters.put(&quot;age&quot;,&quot;30&quot;);

List&lt;Campaign&gt; campaignsResult = getCampaigns(keyValueParameters);
Campaign aCampaign = campaignsResult.get(someIndex);
TargetGroup aTargetGroup = aCampaign.getTargetGroup();
List&lt;TargetValue&gt; targetValues = aTargetGroup.getTargetValues();
targetValues.get(x).getKey() //&quot;gender&quot;
targetValues.get(x).getValue() //&quot;male&quot;
targetValues.get(y).getKey() //&quot;age&quot;
targetValues.get(y).getValue() //&quot;30&quot;
targetValues.get(z).getKey() //some other key
</code></pre>