Grails: Querying Associations causes groovy.lang.MissingMethodException
- by Paul
Hi,
I've got an issue with Grails where I have a test app with:
class Artist {
static constraints = {
name()
}
static hasMany = [albums:Album]
String name
}
class Album {
static constraints = {
name()
}
static hasMany = [ tracks : Track ]
static belongsTo = [artist: Artist]
String name
}
class Track {
static constraints = {
name()
lyrics(nullable: true)
}
Lyrics lyrics
static belongsTo = [album: Album]
String name
}
The following query (and a more advanced, nested association query) works in the Grails Console but fails with a groovy.lang.MissingMethodException when running the app with 'run-app':
def albumCriteria = tunehub.Album.createCriteria()
def albumResults = albumCriteria.list {
like("name", receivedAlbum)
artist { like("name", receivedArtist) } // Fails here
maxResults(1)
}
Stacktrace:
groovy.lang.MissingMethodException: No signature of method: java.lang.String.call() is applicable for argument types: (tunehub.LyricsService$_getLyrics_closure1_closure2) values: [tunehub.LyricsService$_getLyrics_closure1_closure2@604106]
Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), trim()
at tunehub.LyricsService$_getLyrics_closure1.doCall(LyricsService.groovy:61)
at tunehub.LyricsService$_getLyrics_closure1.doCall(LyricsService.groovy)
(...truncated...)
Any pointers?