Quantidade de Registros
18/02/2013 00:08
class Projeto {
static belongsTo = [empresa: Empresa]
static hasMany = [fases: Fase, implementacoes: Implementacao]
...
}
class Fase {
static belongsTo = [projeto: Projeto]
static hasMany = [etapas: Etapa]
...
}
class Etapa {
static belongsTo = [fase: Fase]
static hasMany = [tarefas: Tarefa]
...
}
class Tarefa {
static belongsTo = [etapa: Etapa, implementacao: Implementacao]
static hasMany = [trabalhos: Trabalho]
...
}
int numTarefas = Projeto.withCriteria(uniqueResult: true) {
projetions {
fase {
etapa {
count('tarefa')
}
}
}
}
numero = Projeto.withCriteria(uniqueResult: true) {
projections {
fases {
etapas {
count('tarefas')
}
}
}
}
def p = Projeto.createCriteria()
int num = p.get {
eq 'id', this.id
projections {
fases {
etapas {
tarefas {
count('nome')
}
}
}
}
}
Para se registrar, clique aqui.