title: Defining OR Condition with grails criteria api
body: <p>I have the following domain objects:</p>
  
  <pre><code>class User {
      String name
      Transaction transaction
  
      static constraints = {
          transaction nullable: true
      }
  }
  
  class Transaction {        
      boolean successful
      User user        
      static belongsTo = User
  }
  </code></pre>
  
  <p>I want to select all <code>users</code> that have no successful transaction. This means I want the users without any transaction (<code>transaction == null</code>) and the users that have a transaction with the successful value <code>false</code> (<code>transaction.successful == false</code>). I want to do this with the Criteria API (because this can be combined with other conditions based on user input).</p>
  
  <p>I tried this:</p>
  
  <pre><code>def c = User.createCriteria()
  def results = c {
      or {
          isNull 'transaction'
          transaction {
              eq 'successful', false
          }
      }
  }
  </code></pre>
  
  <p>However this gives me only the users that have a transaction (with the successful value <code>false</code>). But I do not get the users where transaction is <code>null</code></p>
  
  <p>The following code shows how I created some sample data:</p>
  
  <pre><code>def createUserAndTransaction(String name, Boolean successful = null) {
      User u = new User(name: name)
      if (successful != null) {
          Transaction t = new Transaction(user: u, successful: successful)
          u.setTransaction(t)
      }
      u.save()
  }
  
  def init = { servletContext -&gt;
      createUserAndTransaction 'john', true
      createUserAndTransaction 'mike', false
      createUserAndTransaction 'pablo'
  }
  </code></pre>
  
  <p>My criteria query only returns <code>mike</code> in this case. But I want <code>mike</code> and <code>pablo</code>. What am I missing?</p>