class Candidate {
String username;
static HasMany=[applications:Application]
}
class Vote {
String name;
Date firstdate;
Date enddate ;
static HAsMany=[applications:Application]
}
class Application {
Date datedemand;
Candidate candidate;
Vote vote;
static belongsTo = [candidate:Candidate,vote:Vote]
}
我想从 Application in View 中查看候选人的投票。
我开始了以下尝试,但我仍然被阻止:
如果我点击投票,它会向候选人显示此投票
def candidatsGrpByVte(){
def results = Application.withCriteria {
createAlias("vote", "vote")
projections {
groupProperty("vote.name")
}
}
}
def candidatesByVName(def vname){
def results= Application.createCriteria().list() {
createAlias("candidate","candidatAlias")
createAlias("vote","voteAlias")
eq('voteAlias.name',vname)
projections {
property('candidatAlias.username')
}
}
return results;
}