@Id和@Field在同一个变量上? [英] @Id and @Field on same variable?
本文介绍了@Id和@Field在同一个变量上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在@Document
的相同变量上实现@Id
和@Field
,因此该变量也保存在文档中?即使我得到开发人员遵循的设计实践,我仍在尝试尽可能多地保留要导入的数据.
Is there a way to achieve @Id
and @Field
on the same variable of a @Document
so the variable is also saved inside the document? I'm trying to preserve the data I'm importing as much as I can, even though I get the design practices followed by the developers.
推荐答案
@Id注释的优先级高于@Field,因此没有ID不能同时作为文档ID和文档中的值而持久化. 最快的方法可能是将id字段复制为单独的@Field带注释的属性?
The @Id annotation will take priority over @Field, so no the id cannot be persisted as both document ID and value inside the document. Quickest way to achieve that is probably to duplicate the id field as a separate @Field annotated attribute?
这篇关于@Id和@Field在同一个变量上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文