场景是这样的:每个Process
都有多个ProcessingSteps
我编写的代码能够获取所有进程而不对应于ProcessingSteps
.
我知道我缺少 where 子句,我想问一下我们如何在 Grails 中做到这一点。
我只想为每个Process
相应的ProcessingStepUpdate
我有两个域类ProcessingStep
和ProcessingStepUpdate
package a.b.c
public class ProcessingStep {
Process process
}
public class ProcessingStepUpdate{
static belongsTo = [processingStep: ProcessingStep]
ProcessingStep processingStep
}
这是我正在编写的脚本
Process.list(max:1).each {
//List<ProcessingStep> test2= ProcessingStep.findAllByProcess(it)
//println it
def test3 = ProcessingStep.createCriteria().list() {
eq("process",it)
}
println it
it.list().each {
//not telling it where to get the list from
ProcessingStep.list().each { pstep ->
def test4 = ProcessingStepUpdate.createCriteria().list() {
eq("processingStep",pstep)
// Projections are aggregating, reporting, and
// filtering functions that can be applied after
// the query has finished.
// A common use for projections is to summarize data
// in a query
/* projections{
groupProperty("processingStep")
}*/
}
println pstep
//List<ProcessingStepUpdate> test = ProcessingStepUpdate.findAllByProcessingStep(it)
//List<ProcessingStepUpdate> test = ProcessingStepUpdate.findWhere()
//println "it"
}
}
}
一天之内我一直被这个问题困扰.. OOPS 世界的新手!