2015-09-25 17 views
0

我有一個嵌入實體的實體。Objectify LoadException(將V4.1.3升級到V5後)期望的屬性值,但找到...

@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標籤,我得到一個錯誤:

Caused by: com.googlecode.objectify.LoadException: Error loading UserOFY(19001): At path 'lessonSchedule': Expected property value but found: {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

嵌入式實體沒有需要的@Id註釋。

我拿出了StickFigure的建議(在下面的評論中),並簡單地刪除了@Entity和@Id註釋。

+0

或者,您可能已經放棄了@實體和@ Id註解。嵌入的東西不需要是/實體/本身。 – stickfigure

相關問題