我正在尝试在 Grails GORM Mongo 域类中创建一个嵌入式集合。
class User {
String name
Set<String> friends = []
}
我想存储其他用户名的 Set (非重复列表)。
当我尝试保存用户域类时:
new User(name: 'Bob').save(failOnError: true)
我得到了错误。
org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for interface java.util.Set.
将 Set 更改为 List 可以正常工作,但我不想重复,也不想用 List 来管理它。
GORM 有没有办法使用底层的 Mongo$addToSet
功能。