我有一个具有以下字段的实体:
var name: String?,
var metadata: org.bson.Document?,
var things: Map<String, MyObject> = mapOf(),
var other_things: Map<String, MyObject> = mapOf(),
@Indexed(unique = true) var hash: String?
things
和other_things
的键是它们各自的MyObject
对象的哈希值。哈希值中不包含点。当我保存实体时-映射已正确序列化并保存在mongodb中。
一个示例地图-直接从我的mongo控制台获取(我已经屏蔽了MyObject
字段...):
{
"0xa5643bf27e2786816613d3eeb0b62650200b5a98766dfcfd4428f296fb56d043": {
"field": true,
"field1": [
{
"field1field": "foo",
"field1field1": "",
"field1field2": false
}
],
"field2": "sam",
"field3": []
},
"0xfce353f601a3db60cb33e4b6ef4f91e4465eaf93c292b64fcde1bf4ba6819b6a": {
"field": true,
"field1": [
{
"field1field": "bash",
"field1field1": "",
"field1field2": true
}
],
"field2": "bar",
"field3": []
},
"0xcdcd77c0992ec5bbfc459984220f8c45084cc24d9b6efed1fae540db8de801d2": {
"field": true,
"field1": [
{
"field1field": "mash",
"field1field1": "",
"field1field2": false
}
],
"field2": "baz",
"field3": []
}
}
但是,当我检索实体并打印任一地图的键时,每个键前面都有一个.
,即println(entity.things.keys)
的输出是
[.0xa5643bf27e2786816613d3eeb0b62650200b5a98766dfcfd4428f296fb56d043, .0xfce353f601a3db60cb33e4b6ef4f91e4465eaf93c292b64fcde1bf4ba6819b6a, .0xcdcd77c0992ec5bbfc459984220f8c45084cc24d9b6efed1fae540db8de801d2]
我不知道这是怎么回事,有人可以澄清吗?
N.B。地图以前是Map<String, String>
,但我没有这个问题
编辑,我将things
和other_things
更改为List<MySuperObject>
,其中有2个类型分别为String
和MyObject
的字段稍微更改mongodb中的结构(将其保存为数组)-幻影.
不见了-但这不能回答原始问题...