Reputation: 1952
Can somebody provide an example regarding ORMLite with foreign = true
, foreignAutoRefresh = true
using android? A small project in android would be much helpful.
I am trying to create a parent child relationship where child would be provided to parent as a memberField
. Later if parent queried by eg: parent.queryForAll()
, as auto-refresh enabled need not to be queried again.
However, when I query like this I get child is null
. When enabling foreign = true
, is the id field automatically set for child or we need to set it?
Upvotes: 0
Views: 1131
Reputation: 116908
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?
The foreign collection example is a good one to take a look at. There are also working Android examples.
Upvotes: 2