Grails: Querying Associations causes groovy.lang.MissingMethodException

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-10-04T15:39:06Z Indexed on 2010/12/29 21:54 UTC
Read the original article Hit count: 265

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about grails