Google Cloud Datastore/Objectify:与使用 @Serizalize 在 Java 中直接序列化相比,使用 EmbeddedEntity 是否有任何缺点?
我正在尝试将 Java 中的地图对象存储到 Google Cloud Datastore。与直接在字段上使用 @Serizalize
相比,将其视为 EmbeddedEntity
有何缺点?
I am trying to store a map object in Java to Google Cloud Datastore. What are the disadvantages of treating it as EmbeddedEntity
compared to directly using @Serizalize
on the field?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们在大型应用程序中广泛使用基于嵌入式实体的方法,它工作得很好,我真的无法说出任何缺点。
我通常会尽可能避免使用 Java 序列化,如果您尝试更新存储在那里的对象的“架构”,它可能会变得非常麻烦。
We are using an EmbeddedEntity-based approach extensively in a large application and it works just fine, I really can't name any disadvantage.
I would generally avoid using Java serialization where possible, it can become really cumbersome if you try to update the 'schema' of the objects you store there.
可以对嵌入实体建立索引,并根据索引您可以查询子属性。如果您从索引中排除嵌入实体,则所有子属性也会从索引中排除。要了解有关嵌入式实体的更多信息,您可以阅读此文档。
对于可序列化对象,blob 值不会被索引,因此不能在查询过滤器和排序顺序中使用。要了解有关可序列化对象的更多信息,您可以阅读此文档。
因此,使用嵌入式实体没有任何缺点,并且最好使用嵌入式实体,因为它提供了比序列化更多的功能,即可以选择基于索引的查询。
The embedded entities can be indexed and based on the index you can query on subproperties. If you exclude an embedded entity from indexing, then all subproperties are also excluded from indexing. To know more about embedded entities you can go through this document.
With serializable objects the blob values are not indexed and hence can not be used in query filters and sort orders. To know more about serializable objects you can go through this document.
So there is no disadvantage as such while using embedded entities and it is better to use embedded entities as it provides an additional feature over serialization of having the option of index based querying.