如何解决此错误消息?
query did not return a unique result
从这段代码中生成:
try {
crnResults = CRN.where {time == timeParam}.get()
} catch (Exception ex) {
flash.message = ex.message + " -- err: 717"
}
最佳答案
如果您的查询有可能返回多个结果,那么您应该使用 .list()
而不是 .get()
。
要从使用某种排序规则的查询中只获得一个结果,请使用:
crnResults = CRN.where { time == timeParam }.list(max: 1, sort: "id", order: "desc")
否则,只需使用 .list()
。
关于grails - 我怎样才能绕过 : "query did not return a unique result",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31481595/