Exemplo n.º 1
0
  public DbModel findDbModelFirst(DbModelSelector selector) throws DbException {
    if (!tableIsExist(selector.getEntityType())) return null;

    Cursor cursor = execQuery(selector.limit(1).toString());
    if (cursor != null) {
      try {
        if (cursor.moveToNext()) {
          return CursorUtils.getDbModel(cursor);
        }
      } catch (Throwable e) {
        throw new DbException(e);
      } finally {
        IOUtils.closeQuietly(cursor);
      }
    }
    return null;
  }
Exemplo n.º 2
0
  public List<DbModel> findDbModelAll(DbModelSelector selector) throws DbException {
    if (!tableIsExist(selector.getEntityType())) return null;

    List<DbModel> dbModelList = new ArrayList<DbModel>();

    Cursor cursor = execQuery(selector.toString());
    if (cursor != null) {
      try {
        while (cursor.moveToNext()) {
          dbModelList.add(CursorUtils.getDbModel(cursor));
        }
      } catch (Throwable e) {
        throw new DbException(e);
      } finally {
        IOUtils.closeQuietly(cursor);
      }
    }
    return dbModelList;
  }