我有一个嵌入实体的实体。
@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},completedLessons = {},timesAllCompleted = {0},ongoingReviewSchedule = {},revScheduleQueueResetSize = {4},ongoingReviewStats = {},id = {19001},reviewScheduleQueue = {}, reviewSchedule = {},lessonSchedule = [{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?建立关系?
答案 0 :(得分:0)
嵌入式实体没有需要的@Id注释。
我接受了StickFigure的建议(在下面的评论中)并简单地删除了@Entity和@Id注释。