Inheritance domain classes in Grails
- by Tomáš
Hi gurus
how can I get Collection of specific Class?
I use inheriance: On Planet live Human. Humans are dividing to Men and Women.
class Planet{
String name
static hasMany = [ humans : Human ]
}
class Human{
String name
static belongsTo = [Planet]
}
class Man extends Human{
int countOfCar
}
class Woman extends Human{
int coutOfChildren
}
now a neet to get only Collection of Man or Collection of Woman:
get all humans on planet is simple
all = Planet.get(1).humans
but what can I get only woman or men?
womenLivedOnMars = Planet.get(1).getOnlyWoman
menLivedOnJupiter = Planet.get(2).getOnlyMan
Thanks for your help
Tom