【问题标题】:Objectify LoadException (after upgrading V4.1.3 to V5) Expected property value but found...Objectify LoadException(将 V4.1.3 升级到 V5 后)预期的属性值,但发现...
【发布时间】:2015-09-25 15:27:59
【问题描述】:

我有一个带有嵌入式实体的实体。

@Entity @Cache public class UserOFY implements Serializable {
     @Id @Index private Long id;        
     @Unindex public LessonScheduleOFY lessonSchedule;
}

@Entity public class LessonScheduleOFY implements IsSerializable, Serializable {
     @Id @Index private Long id;

}

在 Objectify V4.1.3 中,如果我用 @Embed 标记 LessonScheduleOFY,它可以正常工作。

   @Embed @Entity public class LessonScheduleOFY implements IsSerializable, Serializable {
         @Id @Index private Long id;
    }

当我尝试升级到 V5 时,我运行 ofy().factory().setSaveWithNewEmbedFormat(true);

然后加载我的UserOFY 实体,并保存LessonScheduleOFY 实体以及UserOFY 实体。

但是,当我更改为 V5(从我的类路径中删除 V4)并删除 @Embed 标记时,我收到一个错误:

原因:com.googlecode.objectify.LoadException:加载错误 UserOFY(19001):在路径'lessonSchedule':预期的属性值,但 找到:{reviewing={true},index={1},completeLessons={},timesAllCompleted={0},incomingReviewSchedule={},revScheduleQueueResetSize={4},incomingReviewStats={},id={19001},reviewScheduleQueue= {}, reviewSchedule={}, courseSchedule=[{911}, {912}, {2676}、{2681}、{2696}、{2699}、{2700}、{12001}、{14001}、{17001}、 {4644337115725824}、{4785074604081152}、{5207287069147136}、 {5348024557502464}、{5910974510923776}、{6192449487634432}、 {6333186975989760}、{5488762045857792}、{6614661952700416}]、 nextScheduledLesson={912}, completedLessonDate={}, READY_TO_ADVANCE={true}}

问题:

1) 像 @com.googlecode.objectify.annotation.Serialize private HashMap<Long, Long> completedLessonDate; 这样的东西不能在 V5 的嵌入式类中使用吗?

2) 如果我找不到将 LessonScheduleOFY 用作嵌入式类的方法,我该如何将它迁移到它自己的实体中?使用Ref<?>s 和@Load?建立关系?

【问题讨论】:

    标签: java google-app-engine objectify


    【解决方案1】:

    嵌入的实体没有需要的 @Id 注释。

    我接受了 StickFigure 的建议(在下面的评论中)并简单地删除了 @Entity 和 @Id 注释。

    【讨论】:

    • 或者,您可以删除 @Entity@Id 注释。嵌入的东西不需要是 /entities/ 本身。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 2022-11-17
    • 2021-08-14
    • 1970-01-01
    相关资源
    最近更新 更多