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]
}
我想显示投票列表,如果我点击投票,它会显示该投票的候选人列表。
我开始了以下尝试,但我仍然被阻止:
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;
}
我想在 Application 的投票中看到候选人。
我如何在视图中显示。
你能给我个主意吗?