I have a data model almost identical to the one described in this link - where an object contains a list of another object. And in this case, that object contains a list of another.
When I get my data from the server, I set the references in each side of the objects:
final Dao<SurveyQuestion, Integer> questionDao = Db.get().getTableDao(SurveyQuestion.class);
final Dao<SurveyAnswer, Integer> answerDao = Db.get().getTableDao(SurveyAnswer.class);
for (final Action action : actions) {
tableDao.createOrUpdate(action);
for (final SurveyQuestion question : action.getQuestions()) {
question.setAction(action);
questionDao.createOrUpdate(question);
for (final SurveyAnswer answer : question.getAnswers()) {
answer.setQuestion(question);
answerDao.createOrUpdate(answer);
}
}
}
So I'm calling 'createOrUpdate' on three different tables. The server returns around 300 Action objects, and this is taking around 40-50 seconds to save.
I'm new to Ormlite, so would like to know if it's possible to improve this routine so that it saves much more quickly.