想知道为什么“where”查询在下面的最后一个例子中失败了。情况#5中的where查询没有“where”子句 - 列出所有分配而不是一个。我正在Grails控制台Grails 3.2.5中执行它。
import org.grails.compiler.injection.GrailsAwareClassLoader
def domainName = "Assignment"
def domainPathName = "somepath.$domainName"
def domainClass = new GrailsAwareClassLoader().loadClass(domainPathName)
println "1 -----------"
def c = domainClass.createCriteria()
println c.list {
eq "id", 9361L
}
println "2 -----------"
def wc = domainClass.withCriteria() {
eq "id", 9361L
}
println wc.toList()
println "3 -----------"
def d = new DetachedCriteria(domainClass).build {
eq "id", 9361L
}
println d.list()
println "4 -----------"
def wa = Assignment.where {
id == 9361L
}
println wa.list()
println "5 -----------"
def w = domainClass.where {
id == 9361L
}
println w.list()