2
我正嘗試在Grails GORM Mongo域類中創建嵌入式集合。使用java.util.Set使用Grails 3.1.x和Mongo 5.0.x插件的域屬性
class User {
String name
Set<String> friends = []
}
我想存儲一組用戶的其他名字的(非重複列表)。
當我嘗試保存用戶域類:
new User(name: 'Bob').save(failOnError: true)
我得到的錯誤。
org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for interface java.util.Set.
更改設置爲列表正常工作,但我不想重複,也不想用列表管理。
有沒有辦法讓GORM使用底層的Mongo $addToSet
功能。
你能提供你的堆棧跟蹤? –