Cannot make a LazyForeignCollection become eager collection

。_饼干妹妹 提交于 2019-12-08 02:53:54

问题


I'm getting this error when trying to read a foreign collection from my POJO

AndroidRuntime(589): Caused by: java.lang.IllegalStateException: Internal DAO
    object is null.  Lazy collections cannot be used if they have been deserialized.

The offending collection is answers1 which i have marked as 'eager'

@ForeignCollectionField (eager=true)
private ForeignCollection<TextAnswer> answers1;

Why then when I debug the method below

public List<TextAnswer> getAnswers() {      
    return new ArrayList<TextAnswer>(answers1);
}

That it tells me the collection is a LazyForeignCollection? I am puzzled.

I have no prob with this in any of my other classes that use ForeignCollections :(


回答1:


Lazy collections cannot be used if they have been deserialized.

Interesting problem. First off, that message is only in the LazyForeignCollection class. Is there any chance that the answer1 field used to be lazy and was serialized? Is serialization involved at all? The dao field inside of a ForeignCollection should never be null unless the object has been serialized.

My assumption right now is that you are deserializing a previous version of the class. If this is not the case then I have no idea.



来源:https://stackoverflow.com/questions/13224324/cannot-make-a-lazyforeigncollection-become-eager-collection

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