mongodb - 访问对象列表上的唯一闭包会给出 UnsupportedOperationException

标签 mongodb grails grails-orm

我正在使用 Grails 2.3.11 并使用 MongoDb 插件 mongodb:3.0.3。

我的代码是这样的:

def home() {
   List abcs = ABC.list()
   println abcs.unique { it.parent }
}

代码在访问唯一闭包时中断。

异常说明:

ERROR errors.GrailsExceptionResolver- UnsupportedOperationException   occurred when processing request: [GET] /MongoAppInEcomEnv/product/home
Stacktrace follows:
Message: null
Line | Method
->>  148 | add       in java.util.AbstractList
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    108 | add       in     ''
|    342 | addAll .  in java.util.AbstractCollection
|    120 | $tt__home in com.test.aitm.ProductController$$EPCH6LtA
|    198 | doFilter  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter  in grails.plugin.cache.web.filter.AbstractFilter
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run . . . in java.lang.Thread

最佳答案

看起来列表是空的。

你也可以试试

abcs.parent.unique()

关于mongodb - 访问对象列表上的唯一闭包会给出 UnsupportedOperationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30150267/

相关文章:

python - 使用python flask登录应用程序不重定向到登录页面

javascript - MongoDB 将 mongo 实例包装在 Promise 中

mysql - 戈尔姆 : Query having subquery empty

Grails - 使域类中的嵌入字段可为空

mysql - 服务器 Ajax/http 上的 Nodejs 调用不读取新数据 Mongodb

node.js - 通过远程数据库或rabimtMQ发送db数据

unit-testing - grails 单元测试中的 @ExpectedException

没有持久化的 Grails 实体

grails - 如何从Grails Controller中的参数获取 map ?

hibernate - "Where query"在生产中创建错误的 SQL