title: Grails: Join on two columns of the same table
body: <p>How can I transform this SQL Query to a criteria or HQL query in grails </p>
  
  <pre><code>select  distinct(x.id) 
  FROM y INNER JOIN x ON y.x_id =x.id  OR y.x2_id=x.id
  </code></pre>
  
  <p>where x_id and x2_id are foreign keys for x table </p>