I have a nasty problem with the criteria builder. I have an application in which one user has one calendar, and the calendar has many entries. It seems simple enough, but when I try to get calendar entries for a given user, I cannot access the user property (MissingMethodException). Here is the code:
def getEntries(User user) { def entries = [ClassName].createCriteria().list() { calendar { user { eq("id", user.id) } } } }
I even tried the following variation:
def getEntries(User user) { def entries = [ClassName].createCriteria().list() { calendar { eq("user", user) } } }
This did not throw an exception, but also did not work.
Here are the relevant parts of the domain classes:
class Calendar { static belongsTo = [user: User] static hasMany = [entries: Entries] ... } class User { Calendar calendar ... } class Entry { static belongsTo = [calendar: Calendar] ... }
When Googling, I ran into a similar issue noted in early 2008: http://jira.codehaus.org/browse/GRAILS-1412
But according to this link, this issue should have been resolved a long time ago.
What am I doing wrong?
source share