示例#1
0
 private void exeSqlInfo(SqlInfo sqlInfo) {
   if (sqlInfo != null) {
     debugSql(sqlInfo.getSql());
     db.execSQL(sqlInfo.getSql(), sqlInfo.getBindArgsAsArray());
   } else {
     KJLoger.debug(getClass().getName() + "sava error:sqlInfo is null");
   }
 }
示例#2
0
 /**
  * 根据主键查找数据(默认不查询多对一或者一对多的关联数据)
  *
  * @param id
  * @param clazz
  */
 public <T> T findById(Object id, Class<T> clazz) {
   checkTableExist(clazz);
   SqlInfo sqlInfo = SqlBuilder.getSelectSqlAsSqlInfo(clazz, id);
   if (sqlInfo != null) {
     debugSql(sqlInfo.getSql());
     Cursor cursor = db.rawQuery(sqlInfo.getSql(), sqlInfo.getBindArgsAsStringArray());
     try {
       if (cursor.moveToNext()) {
         return CursorHelper.getEntity(cursor, clazz, this);
       }
     } catch (Exception e) {
       e.printStackTrace();
     } finally {
       cursor.close();
     }
   }
   return null;
 }