I have a simple Grails application. I have domains as below
class Author implements Serializable {
....
static hasMany = [
book : Book
]
}
class Book implements Serializable{
Author author
Genres genres
static belongsTo = [author: Author , genre: Genres ]
static mapping = {
.....
author lazy: false
}
}
class Genres implements Serializable{
String title
}
Now I have a requirement where I have a list of Genres title, I need to retrieve all the authors who has atleast one book in one of those Genres. I need to write a named query in Author class. I tried the following query
hasGenre {cl ->
'book.genre.title' in cl
}
And I pass a list of string as follows
Author.hasGenre(genereTitleStringArray)
But this does not seems to be working. I have some other straightforward named-queries which works fine. So when I retrieve including "hasGenere" this does not seem to affect the retrieval. What am i doing wrong? I'm quite new to this area
Thanks in advance