title: distinct inner join hql
body: <p>I've the following hibernate entities</p>
  
  <pre><code>public class Container {
    ...
  
    @OneToMany
    private List&lt;ACLEntry&gt; aclEntries;
  }
  </code></pre>
  
  <p>For securing my container instances i use the following entity:</p>
  
  <pre><code>public class ACLEntry {
  
    ...
    private Long sid;
    private boolean principal;
    private Integer mask;
  
  }
  </code></pre>
  
  <p>The hql-queries will be created automatically so for searching container instances, 
  the following query will be created:</p>
  
  <pre><code>select container from Container container 
  inner join container.aclEntries as aclEntry 
  with bitwise_and (aclEntry.mask, 1) = 1 and 
     (aclEntry.sid = :userId or aclEntry.sid = :roleId)  
  </code></pre>
  
  <p>The problem with this is, that the aclentry join could return 2 results which will result in duplicate container results.</p>
  
  <p>Has anyone an idea how to solve this ?</p>