ORMLite对外收集和序列化
如何使用 ORMLite ForeignCollection
在两个活动之间发送对象? ForeignCollection
是不可序列化的吗?我收到 IOException ,这是由于不可序列化对象造成的。
例如:在
@ForeignCollectionField(eager = false)
private transient ForeignCollection<CallObjective> _callObjectives;
My CallObjective 类中的 My Call 类中:
@DatabaseField(columnName = "CallId", foreign = true, foreignAutoRefresh = true)
private Call _call;
How to send an object with ORMLite ForeignCollection
between two activities ? Is that ForeignCollection
is non serializable ? I'm getting the IOException
which is due to non serializable object.
Ex: in My Call class
@ForeignCollectionField(eager = false)
private transient ForeignCollection<CallObjective> _callObjectives;
in My CallObjective class:
@DatabaseField(columnName = "CallId", foreign = true, foreignAutoRefresh = true)
private Call _call;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 ORMLite 版本 4.26 中,我们对
EagerForeignCollection
类进行了一些改进,使其更加可序列化。前几天我在主干中发现了一个错误,实际上[不幸的是]阻止了您与eager = false
一起使用的LazyForeignCollection
类的序列化。这将在 4.28 版本中修复。即使集合是可序列化的,您也无法对惰性集合执行任何操作,因为上下文太多,无法正确反序列化它。它将是一个在大多数操作上抛出异常的 shell。
In version 4.26 of ORMLite we made some improvements to the
EagerForeignCollection
class to make it more serializable. I found a bug in trunk the other day actually that [unfortunately] stops theLazyForeignCollection
class which you are using with theeager = false
from being serializable. That will be fixed in version 4.28.Even if the collection was serializable, you would not be able to do anything with the lazy collections because there is too much context to be able to deserialize it properly. It will be a shell that throws exceptions on most operations.