How can I fill the foreign collection manually

后端 未结 1 1594
失恋的感觉
失恋的感觉 2021-01-24 19:16

I have:

@ForeignCollectionField(eager = false)
private ForeignCollection fieldCollection;

and I want to fill this collection from

1条回答
  •  深忆病人
    2021-01-24 19:18

    ... I want to fill this collection from data coming from web service because I want to insert this data to my Sqlite database.

    Right. The serialization error message is misleading. You are trying to create a foreign collection and you can't call the constructor directly. You should instead be calling

    dao.assignEmptyForeignCollection(data, "entitiyCollection");
    

    or

    data.entitiyCollection = dao.getEmptyForeignCollection("entitiyCollection");
    

    This wires the appropriate DAO object into the foreign collection. I've improved the javadocs and the error message.

    https://github.com/j256/ormlite-core/commit/b4037999c21f45c426ce7a83bc759e3ec8335c61

    0 讨论(0)
提交回复
热议问题