春季数据mongodb"id"场图 [英] spring data mongodb "id" field mapping
本文介绍了春季数据mongodb"id"场图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文档,其中的数组字段为
I have a document with an array field with
"chapters": [
{ "id" : "14031871223912313", ...}
...
]
我想使用以下命令查询带有Spring Data的MongoTemplate的ID:
I would like to query return the id's with Spring Data's MongoTemplate using the following:
class Chapter {
private String id;
public String getId() {
return id;
}
}
这样,不会填充ID.我尝试将不同的映射选项与@Field结合使用,此处
This way the id is not populated. I have tried using the different mapping options with @Field described here http://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mapping.conventions.id-field
我做错了什么?我知道我总是可以回到mongo java驱动程序,但是我认为这应该可行.
What am I doing wrong? I know I can always to back to mongo java driver, but I thought this should work.
在此先感谢您的帮助.
推荐答案
找到了解决方案.它是通过以下方式填充的:
Found a solution. It is populated via:
@Field("id")
private String chaperId
这篇关于春季数据mongodb"id"场图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文