I have:
@ForeignCollectionField(eager = false)
private ForeignCollection<Field> fieldCollection;
我想用来自 Web 服务的数据填充这个集合,因为我想将此数据插入到我的 Sqlite 数据库中。
我尝试使用这个:
boolean accessOnPremiseDb = false;
String description;
@ForeignCollectionField(eager = false)
private ForeignCollection<Entity> entitiyCollection =
new LazyForeignCollection<Entity, Integer>(null, accessOnPremiseDb,
accessOnPremiseDb, null, description, accessOnPremiseDb);
但我得到了错误
Caused by: java.lang.IllegalStateException: Internal DAO object is null.
Lazy collections cannot be used if they have been deserialized.
我怎样才能毫无问题地做到这一点?我应该为此创建新变量吗?
...我想用来自 Web 服务的数据填充此集合,因为我想将此数据插入到我的 Sqlite 数据库中。
正确的。序列化错误消息具有误导性。您正在尝试创建一个外部集合,并且无法直接调用构造函数。你应该打电话
dao.assignEmptyForeignCollection(data, "entitiyCollection");
or
data.entitiyCollection = dao.getEmptyForeignCollection("entitiyCollection");
这会将适当的 DAO 对象连接到外部集合中。我改进了 javadocs 和错误消息。
https://github.com/j256/ormlite-core/commit/b4037999c21f45c426ce7a83bc759e3ec8335c61
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)