我正在测试 Ormlite 的性能,我对此印象深刻。那怎么可能testORMLITE_jobget()
更快testORMLITE_getcursor()
呢?
public void testORMLITE_jobget() throws SQLException {
Dao<Job, Integer> dao = dbhelper.getJobDao();
List<Job> jobs = dao.queryForAll();
for (Job job : jobs) {
Log.i("OrmLite", job.getName());
}
dbhelper.close();
}
public void testORMLITE_getcursor() throws SQLException {
SQLiteDatabase db = dbhelper.getReadableDatabase();
Cursor c = db.rawQuery("select * from job", null);
if (c.moveToFirst())
while (c.moveToNext()) {
Log.i("Cursor", c.getString(c.getColumnIndex("name")));
}
c.close();
db.close();
}
第二个问题:我是否以这种方式正确删除了外国收藏?
public void testORMLITE_jobdelete() throws SQLException{
Job j = dbhelper.getJobDao().queryForId(5);
dbhelper.getTagDao().delete(j.tags);
dbhelper.getJobDao().delete(j);
}