我的mongoDB中只有一个文档。这是:
{
"_id": "32fqwefr",
"propertyName": "configShowableField",
"Applicant": [
"R:a_FII",
"R:a_PN"
],
"Employment": [
"R:a_FIIq",
"R:a_PsN"
],
"Product": [
"R:a_FII",
"R:a_PN"
],
"Address": [
"R:a_FII",
"R:a_PN"
]
}
并返回该文档。
我已经查询了它
Map<String, List<String>> configShowable = new HasMapsh<>();
Query query = new Query();
query.addCirteria(Criteria.where("propertyName").is("configShowableField"));
Map<String. Object> config = getMongoTemplate.findOne(query, Map.class,"Collection");
config.forEach(k,v)->{
if(v instanceof List){
configShowable.put(k, (List<String>V));
}
}
return configShowable;
问题是configShowable
订单被改变了,我不需要。我需要我返回插入数据库中的相同内容,换句话说,地图比创建时更糟糕。
〔实施例:
{
"_id": "32fqwefr",
"propertyName": "configShowableField",
"Address": [
"R:a_FII",
"R:a_PN"
],
"Applicant": [
"R:a_FII",
"R:a_PN"
],
"Product": [
"R:a_FII",
"R:a_PN"
],
"Employment": [
"R:a_FIIq",
"R:a_PsN"
]
}
我该如何预防这种疾病?
答案 0 :(得分:0)
我建议您使用LinkedHaskMap,按照插入顺序保存密钥