class Animal{ ... }
class Tiger extends Animal { ... }
class Deer extends Animal { ... }
Now I wanted to have a namedQuery as
class Animal {
...
static namedQueries = {
findAllAnimalBySpecies{
... some logic for fetch only Tiger
... some logic for fetch only Deer
}
}
}
In controller,
def tigers = Animal.findAllAnimalBySpecies().list()
How is it possible to fetch only "Tiger"s by querying the Animal? Or i am missing proper concept.
Give this a try:
and then:
def tigers = Animal.findAllAnimalBySpecies('tiger').list()