0

有人可以使用android提供一个关于ORMLite的例子foreign = true吗?foreignAutoRefresh = trueandroid中的一个小项目会很有帮助。

我正在尝试创建一个父子关系,其中子将作为memberField. 稍后如果通过 eg: 查询父parent.queryForAll()级,则由于启用了自动刷新,因此无需再次查询。

但是,当我这样查询时,我得到 child is null。启用foreign = true时,id字段是自动为child设置还是我们需要设置?

4

1 回答 1

2

I suspect that you are forgetting to add the child object to the database. The typical pattern is to store the child object to the database using its own DAO and then set the child on the parent before persisting the parent to the database. The child does not get automatically written to the database. There is a foreignAutoCreate = true feature that was added recently that will help with this.

There are a number of examples on the website for ORMLite. Do none of them work? We've spent a long time on the documentation. Have you looked at it at all?

http://ormlite.com/docs/examples

The foreign collection example is a good one to take a look at. There are also working Android examples.

http://ormlite.com/docs/android-examples

于 2011-11-08T12:31:25.403 回答