java如何手动填充外部集合
我有:
@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.
我怎样才能毫无问题地做到这一点?我应该为此创建新变量吗
# 1 楼答案
对。序列化错误消息具有误导性。您正在尝试创建外部集合,无法直接调用构造函数。你应该打电话
或
这会将适当的DAO对象连接到外部集合中。我改进了javadocs和错误消息