Embedded entity reading from originaly stored as Blob

蓝咒 提交于 2021-01-29 06:38:31

问题


Migrating from AppEngine low level Datastore API to objectify 5: reading Entity gets an error.

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;

How do we read this Blob data?


回答1:


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;

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



来源:https://stackoverflow.com/questions/62951695/embedded-entity-reading-from-originaly-stored-as-blob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!