嵌入式实体从存储为Blob的原始数据读取 [英] Embedded entity reading from originaly stored as Blob
问题描述
从AppEngine低级数据存储区API迁移到对象5:读取Entity会出错.
Migrating from AppEngine low level Datastore API to objectify 5: reading Entity gets an error.
我使用数据存储区实体工具看到的是因为旧数据保留了"Ifont".为"斑点"而是应该成为"嵌入式类"
What i see using the Datastore Entity Tool is because the old data keeps "Ifont" as "Blob" instead and should become an "Embedded class"
@Entity(name = "Mandant")
public class Mandant implements IsSerializable {
@Id
private Long id;
@Index
private String nr = "";
private Ifont fontHeader;
我们如何读取此Blob数据?
How do we read this Blob data?
推荐答案
首先如何将数据保存到Blob字段中?Blob只是一个字节数组;可能是任何东西.如果您使用Java序列化写出了Ifont(看起来很可能来自您的示例),这很容易-只需像下面这样声明该字段即可:
How did you save the data into a Blob field in the first place? A Blob is just a byte array; it could be anything. If you wrote the Ifont out using Java serialization (seems likely from your example), this is easy - just declare that field like this:
private @Serialize Ifont fontHeader;
这将保留Blob结构.但是,如果您实际上希望将其存储为EmbeddedEntity,则需要迁移数据.这里有一些建议的策略:
That will preserve the Blob structure. However, if you actually want it stored as EmbeddedEntity, you'll need to migrate the data. There are some strategies suggested here:
https://github.com/objectify/objectify/wiki/SchemaMigration
这篇关于嵌入式实体从存储为Blob的原始数据读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!