title: Grails: Problem with nested associations in criteria builder
body: <p>I have a frustrating problem with the criteria builder. I have an application in which one user has one calendar, and a calendar has many entries. Seems straightforward enough, but when I try to get the calendar entries for a given user, I can't access the user property (MissingMethodException). Here's the code:</p>
  
  <pre><code>def getEntries(User user) {
    def entries = [ClassName].createCriteria().list() {
      calendar {
        user {
          eq("id", user.id)
        }
      }
    }
  }
  </code></pre>
  
  <p>I have even tried the following variation:</p>
  
  <pre><code>def getEntries(User user) {
    def entries = [ClassName].createCriteria().list() {
      calendar {
        eq("user", user)
      }
    }
  }
  </code></pre>
  
  <p>That did not raise an exception, but didn't work either.</p>
  
  <p>Here's the relevant parts of the domain classes:</p>
  
  <pre><code>class Calendar {
      static belongsTo = [user: User]
      static hasMany = [entries: Entries]
  
      ...
  }
  
  class User {
      Calendar calendar
  
      ...
  }
  
  class Entry {
      static belongsTo = [calendar: Calendar]
  
      ...
  }
  </code></pre>
  
  <p>When Googling I came across a similar problem noted in early 2008:
  <a href="http://jira.codehaus.org/browse/GRAILS-1412" rel="nofollow noreferrer">http://jira.codehaus.org/browse/GRAILS-1412</a></p>
  
  <p>But according to that link this issue should have been solved long ago.</p>
  
  <p>What am I doing wrong?</p>