@Override public long queryCount(QueryBuilder qb) { acquireReference(); try { SQLiteDatabase db = mHelper.getReadableDatabase(); SQLStatement stmt = qb.createStatementForCount(); return stmt.queryForLong(db); } catch (Exception e) { e.printStackTrace(); } finally { releaseReference(); } return SQLStatement.NONE; }
@Override public int delete(Class<?> claxx, WhereBuilder where) { acquireReference(); try { EntityTable table = TableManager.getTable(claxx); if (table.key != null && !Checker.isEmpty(table.mappingList)) { List<?> list = query(QueryBuilder.create(claxx).columns(new String[] {table.key.column}).where(where)); delete(list); } else { return where.createStatementDelete(claxx).execDelete(mHelper.getWritableDatabase()); } } catch (Exception e) { e.printStackTrace(); } finally { releaseReference(); } return SQLStatement.NONE; }
@Override public <T> ArrayList<T> query(QueryBuilder qb) { SQLiteDatabase db = mHelper.getReadableDatabase(); // mTableManager.checkOrCreateTable(db, qb.getQueryClass()); return qb.createStatement().query(db, qb.getQueryClass()); }