I have a simple Grails application. I have a couple of domains such as following. The scenario is Person has many Telephone (But person class does not have a list of telephone as a variable : Lazy Single-Ended Associations).
class Person implements Serializable {
....
}
class Telephone implements Serializable{
String number
static belongsTo = [person : Person]
static mapping = {
.....
person lazy: false
}
}
Now I have a requirement where I have to search the person by telephone numbers. I have a list of string telephone numbers. I need to get all the persons whom have at least one of that telephone number. I need to write namedQueries, but I'm quite new to this area. Is it possible to write named queries for this? Or do I need a mapping defined in Person class as
set telephone
static hasMany = [
telephone: Telephone
]
And how would the namedQueries should be defined to suit my requirement
Thanks in advance