private void insertAnswers() {
DbSession dbSession = AppCore.ref.createDbSession();
DbOomQuery dbQuery = new DbOomQuery(dbSession, DbSqlBuilder.sql("select $C{q.*} from $T{Question q} order by $q.id"));
List<Question> questions = dbQuery.list();
dbQuery.close();
for(Question q : questions) {
dbQuery = new DbOomQuery(dbSession, DbSqlBuilder.sql("select $C{a.*} from $T{Answer a} where $a.questionId=:questionId"));
dbQuery.setLong("questionId", q.getId());
List<Answer> answers = dbQuery.list();
dbQuery.close();
for (Answer a : answers) {
dbQuery = new DbOomQuery(dbSession, DbEntitySql.updateColumn(a, "votes", Integer.valueOf(MathUtil.randomInt(10, 50))));
dbQuery.autoClose().executeUpdate();
}
}
}