title: Find all objects with value in list
body: <p>I'm introducing myself to the Grails environment (It's <em>awesome</em>). I've been reaping the benefits of dynamically generated methods like the <code>findAllBy*</code> range. However, I've come to a problem and I'm unsure about how to proceed. An hour spent on Google didn't yield all that much for me either.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>I have a class like the following:</p>
  
  <pre><code>class Runner {
  
      static hasMany = [owners: Owner]
  }
  </code></pre>
  
  <p>And in my Owner controller, I wish to find all <code>Runner</code> objects, that contain a given <code>Owner</code>. Effectively, I'm trying to go from the <code>many</code> to the <code>one</code>.</p>
  
  <p><strong>Example</strong></p>
  
  <p>If I have an <code>Owner</code> object, that looks something like</p>
  
  <pre><code>Owner[name="Dave"]
  </code></pre>
  
  <p>And I have a <code>Runner</code> with something like:</p>
  
  <pre><code>Runner[owners[Owner[name="Dave"], Owner[name="James"]]]
  </code></pre>
  
  <p>My query should return this <code>Runner</code> object, but it should not return</p>
  
  <pre><code>Runner[owners[Owner[name="Bill"], Owner[name="James"]]]
  </code></pre>
  
  <p><strong>My attempts</strong></p>
  
  <p>I've attempted to use the <code>inList</code> extension, but after some further research I realised that was designed for the other way around. My code at the moment is as follows:</p>
  
  <pre><code>def runners() {
      log.info("Runners")
      List&lt;Runner&gt; runners;
      Owner owner;
  
      if (params.id) {
          log.info("Id = " + params.id);
          owner = Owner.get(params.id);
          log.info("owner = " + owner.name);
          // Grab runners in list thing.
          log.info("Number of results = " + runners.size());
      }
  
  
      [results: results, jockeyInstance: jockey]
  }
  </code></pre>