@SuppressWarnings("unchecked") protected <T>List<T> query(Class<T> modelClass,String[] columns,String selection,String[] selectionArgs,String groupBy,String having,String orderBy,String limit,List<AssociationsInfo> foreignKeyAssociations){
  List<T> dataList=new ArrayList<T>();
  Cursor cursor=null;
  try {
    List<Field> supportedFields=getSupportedFields(modelClass.getName());
    String tableName=getTableName(modelClass);
    String[] customizedColumns=getCustomizedColumns(columns,foreignKeyAssociations);
    cursor=mDatabase.query(tableName,customizedColumns,selection,selectionArgs,groupBy,having,orderBy,limit);
    if (cursor.moveToFirst()) {
      SparseArray<QueryInfoCache> queryInfoCacheSparseArray=new SparseArray<QueryInfoCache>();
      do {
        T modelInstance=(T)createInstanceFromClass(modelClass);
        giveBaseObjIdValue((DataSupport)modelInstance,cursor.getLong(cursor.getColumnIndexOrThrow("id")));
        setValueToModel(modelInstance,supportedFields,foreignKeyAssociations,cursor,queryInfoCacheSparseArray);
        if (foreignKeyAssociations != null) {
          setAssociatedModel((DataSupport)modelInstance);
        }
        dataList.add(modelInstance);
      }
 while (cursor.moveToNext());
      queryInfoCacheSparseArray.clear();
    }
    return dataList;
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new DataSupportException(e.getMessage());
  }
 finally {
    if (cursor != null) {
      cursor.close();
    }
  }
}

@ SuppressWarnings ( "unchecked" ) protected < T > List < T > query ( Class < T > modelClass , String [ ] columns , String selection , String [ ] selectionArgs , String groupBy , String having , String orderBy , String limit , List < AssociationsInfo > foreignKeyAssociations ) { List < T > dataList = new ArrayList < T > ( ) ; Cursor cursor = null ; try { List < Field > supportedFields = getSupportedFields ( modelClass . getName ( ) ) ; String tableName = getTableName ( modelClass ) ; String [ ] customizedColumns = getCustomizedColumns ( columns , foreignKeyAssociations ) ; cursor = mDatabase . query ( tableName , customizedColumns , selection , selectionArgs , groupBy , having , orderBy , limit ) ; if ( cursor . moveToFirst ( ) ) { SparseArray < QueryInfoCache > queryInfoCacheSparseArray = new SparseArray < QueryInfoCache > ( ) ; do { T modelInstance = ( T ) createInstanceFromClass ( modelClass ) ; giveBaseObjIdValue ( ( DataSupport ) modelInstance , cursor . getLong ( cursor . getColumnIndexOrThrow ( "id" ) ) ) ; setValueToModel ( modelInstance , supportedFields , foreignKeyAssociations , cursor , queryInfoCacheSparseArray ) ; if ( foreignKeyAssociations != null ) { setAssociatedModel ( ( DataSupport ) modelInstance ) ; } dataList . add ( modelInstance ) ; } while ( cursor . moveToNext ( ) ) ; queryInfoCacheSparseArray . clear ( ) ; } return dataList ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new DataSupportException ( e . getMessage ( ) ) ; } finally { if ( cursor != null ) { cursor . close ( ) ; } } }
query the table of the given model , returning a model list over the result set .
