ORMLite foreign collection and serialization

2k views Asked by At

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;
1

There are 1 answers

1
Gray On BEST ANSWER

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 the LazyForeignCollection class which you are using with the eager = 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.