Google Cloud Datastore/Objectify:与使用 @Serizalize 在 Java 中直接序列化相比,使用 EmbeddedEntity 是否有任何缺点?

发布于 2025-01-15 21:35:11 字数 128 浏览 2 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

春风十里 2025-01-22 21:35:11

我们在大型应用程序中广泛使用基于嵌入式实体的方法,它工作得很好,我真的无法说出任何缺点。

我通常会尽可能避免使用 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.

像你 2025-01-22 21:35:11

可以对嵌入实体建立索引,并根据索引您可以查询子属性。如果您从索引中排除嵌入实体,则所有子属性也会从索引中排除。要了解有关嵌入式实体的更多信息,您可以阅读此文档。

对于可序列化对象,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文