【问题标题】:Embedded entity reading from originaly stored as Blob从原始存储为 Blob 的嵌入式实体读取
【发布时间】:2020-11-07 03:00:52
【问题描述】:

从 AppEngine 低级 Datastore API 迁移到 objectify 5:读取 Entity 时出错。

我看到使用数据存储实体工具是因为旧数据将“Ifont”保留为“Blob”,应该成为“嵌入式类

@Entity(name = "Mandant")
public class Mandant implements IsSerializable {
        @Id
    private Long id;
    @Index
    private String nr = "";
    private Ifont fontHeader;

我们如何读取这个 Blob 数据?

【问题讨论】:

  • Ifont 类没有@Id

标签: java google-app-engine google-cloud-datastore objectify


【解决方案1】:

您最初是如何将数据保存到 Blob 字段中的? Blob 只是一个字节数组;它可以是任何东西。如果您使用 Java 序列化(似乎可能来自您的示例)编写了 Ifont,这很容易 - 只需像这样声明该字段:

private @Serialize Ifont fontHeader;

这将保留 Blob 结构。但是,如果您确实希望将其存储为 EmbeddedEntity,则需要迁移数据。这里建议了一些策略:

https://github.com/objectify/objectify/wiki/SchemaMigration

【讨论】:

  • 我只是使用了旧的注解@Persistant。我会尝试你的建议?并跟进我的结果。
猜你喜欢
  • 2020-11-12
  • 1970-01-01
  • 1970-01-01
  • 2012-06-16
  • 1970-01-01
  • 2019-07-29
  • 1970-01-01
  • 2019-12-07
  • 2017-09-26
相关资源
最近更新 更多