title: How to use grails GORM to do left outer join with multiple field matches?
body: <p>We have a need to do the following with our grails project:</p>
  
  <pre><code>select * from message m  
  LEFT JOIN votes v ON v.message_id = m.id and v.user_id = 1 
  where parent_id is null;
  </code></pre>
  
  <p>The domain classes are fairly simple:</p>
  
  <pre><code>class Message {
  
      String text
      User user
  
      static belongsTo = [parent:Message]
  
      static hasMany = [messages:Message, votes:Votes]
  
      static constraints = {
          parent nullable: true
      }
  
      static mapping = {
          votes lazy: false
      }
  }
  
  class Votes {
  
      User user
      Message message
      int vote = 0
  
      static belongsTo = [user:User, message:Message]
  
      static constraints = {
      }
  
      static mapping = {
          vote defaultValue: 0
      }
  }
  </code></pre>
  
  <p>So far we were able to get <code>v.message_id = m.id</code> condition to work but unable to add <code>and v.user_id = 1</code> condition to the LEFT OUTER JOIN.</p>
  
  <p>Here is the Controller code:</p>
  
  <pre><code>    def test = Message.withCriteria {
  
          isNull('parent')
          createAlias('votes', 'v', CriteriaSpecification.LEFT_JOIN)
  
      } 
  </code></pre>
  
  <p>Any ideas how to do that? </p>