I'm using Grails 2.4.4. I've got domain class
class Purchase {
static hasMany = [dataList:DataByPeriod]
String name
Set<DataByPeriod> dataList
public Set<DataByPeriod> getDataList(){
dataList?.findAll { (!it.isDeleted) }
}
def getPeriodList(){
this.dataList?.period?.unique()?.sort{it.name}
}
}
and another two:
class DataByPeriod {
static belongsTo = [purchase:Purchase, period:Period]
Long value
}
class Period {
static hasMany = [dataList:DataByPeriod]
String name
}
Now I want to receive all periods for given purchaseInstance. If I do:
purchaseInstance?.dataList?.period?.unique()?.sort{it.name}
I'll get correct data (getter for dataList
will be called and all records with isDeleted==true
will be ignored
But if I I do: purchaseInstance?.getPeriodList() getter will not be called and all records will be shown?
Why does this happens? Why I even cannot change my 'getPeriodList()` method to:
def getPeriodList(){
this.getDataList()?.period?.unique()?.sort{it.name}
}
It says that 'there is no method getDataList() for class Purchase'.