Grails: query associations raise groovy.lang.MissingMethodException

I have a problem with Grails, where I have a test application 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 request (and a more advanced nested association request) works in the Grails console, but when the application starts with "run-app", groovy.lang.MissingMethodException is executed:

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?

+3
source share
2 answers

What exactly does this restriction mean? Seems suspicious to me ...

static constraints = {
    name()
}

- Is this what you want?

static constraints = {
    name(nullable:false, blank: false)
}
0
source

Grails. , , GORM . , DomainClass.list() . findAll() , . . .methods() , Groovy Grails, , GORM, , . BootStrap .

, , Grails Mac, Windows. , ? , Grails 1.3.6 Windows ?

0

Source: https://habr.com/ru/post/1767898/


All Articles