Example #1
0
 /** @see #paginateByCache(String, Object, int, int, String, String, Object...) */
 public static Page<Record> paginateByCache(
     String cacheName,
     Object key,
     int pageNumber,
     int pageSize,
     String select,
     String sqlExceptSelect) {
   return dbPro.paginateByCache(cacheName, key, pageNumber, pageSize, select, sqlExceptSelect);
 }
Example #2
0
 static Page<Record> paginate(
     Config config,
     Connection conn,
     int pageNumber,
     int pageSize,
     String select,
     String sqlExceptSelect,
     Object... paras)
     throws SQLException {
   return dbPro.paginate(config, conn, pageNumber, pageSize, select, sqlExceptSelect, paras);
 }
Example #3
0
  public void intercept(final Invocation inv) {
    Config config = Tx.getConfigWithTxConfig(inv);
    if (config == null) config = DbKit.getConfig();

    if (actionKeySet.contains(inv.getActionKey())) {
      DbPro.use(config.getName())
          .tx(
              new IAtom() {
                public boolean run() throws SQLException {
                  inv.invoke();
                  return true;
                }
              });
    } else {
      inv.invoke();
    }
  }
 /** 删除后,大于rc_sort的记录自动减一 */
 public boolean deleteAfter_minus(int rc_sort, int c_id) {
   int count =
       DbPro.use()
           .update(
               "update  "
                   + TableName
                   + " set rc_sort = rc_sort-1   where rc_sort > ? and c_id = ?",
               rc_sort,
               c_id);
   if (count > 0) {
     // 删除成功后,异动表中也应该总步骤减一
     Change.me.updateSteps_minus(c_id);
     return true;
   } else {
     return false;
   }
 }
Example #5
0
 /** @see #findByCache(String, Object, String, Object...) */
 public static List<Record> findByCache(String cacheName, Object key, String sql) {
   return dbPro.findByCache(cacheName, key, sql);
 }
Example #6
0
 /**
  * Execute transaction with default transaction level.
  *
  * @see #tx(int, IAtom)
  */
 public static boolean tx(IAtom atom) {
   return dbPro.tx(atom);
 }
Example #7
0
 public static String queryStr(String sql) {
   return dbPro.queryStr(sql);
 }
Example #8
0
 /**
  * @see #queryFirst(String, Object...)
  * @param sql an SQL statement
  */
 public static <T> T queryFirst(String sql) {
   return dbPro.queryFirst(sql);
 }
Example #9
0
 public static <T> T queryColumn(String sql) {
   return dbPro.queryColumn(sql);
 }
Example #10
0
 /** @see #batch(String, String, Object[][], int) */
 public static int[] batch(String sql, Object[][] paras, int batchSize) {
   return dbPro.batch(sql, paras, batchSize);
 }
Example #11
0
 static <T> List<T> query(Config config, Connection conn, String sql, Object... paras)
     throws SQLException {
   return dbPro.query(config, conn, sql, paras);
 }
Example #12
0
 static boolean update(
     Config config, Connection conn, String tableName, String primaryKey, Record record)
     throws SQLException {
   return dbPro.update(config, conn, tableName, primaryKey, record);
 }
Example #13
0
 /**
  * Update Record.
  *
  * <pre>
  * Example:
  * Db.update("user_role", "user_id, role_id", record);
  * </pre>
  *
  * @param tableName the table name of the Record save to
  * @param primaryKey the primary key of the table, composite primary key is separated by comma
  *     character: ","
  * @param record the Record object
  * @param true if update succeed otherwise false
  */
 public static boolean update(String tableName, String primaryKey, Record record) {
   return dbPro.update(tableName, primaryKey, record);
 }
Example #14
0
 /** @see #save(String, String, Record) */
 public static boolean save(String tableName, Record record) {
   return dbPro.save(tableName, record);
 }
Example #15
0
 /** @see #query(String, String, Object...) */
 public static <T> List<T> query(String sql, Object... paras) {
   return dbPro.query(sql, paras);
 }
Example #16
0
 /** @see #paginate(String, int, int, String, String, Object...) */
 public static Page<Record> paginate(
     int pageNumber, int pageSize, String select, String sqlExceptSelect) {
   return dbPro.paginate(pageNumber, pageSize, select, sqlExceptSelect);
 }
Example #17
0
 /** @see #findFirstByCache(String, Object, String, Object...) */
 public static Record findFirstByCache(String cacheName, Object key, String sql) {
   return dbPro.findFirstByCache(cacheName, key, sql);
 }
Example #18
0
 /** @see #batch(String, String, String, List, int) */
 public static int[] batch(String sql, String columns, List modelOrRecordList, int batchSize) {
   return dbPro.batch(sql, columns, modelOrRecordList, batchSize);
 }
Example #19
0
 /**
  * Update record with default primary key.
  *
  * <pre>
  * Example:
  * Db.update("user", record);
  * </pre>
  *
  * @see #update(String, String, Record)
  */
 public static boolean update(String tableName, Record record) {
   return dbPro.update(tableName, record);
 }
Example #20
0
 /**
  *
  *
  * <pre>
  * Example:
  * boolean succeed = Db.delete("user", user);
  * </pre>
  *
  * @see #delete(String, String, Record)
  */
 public static boolean delete(String tableName, Record record) {
   return dbPro.delete(tableName, record);
 }
Example #21
0
 /**
  * Execute sql query and return the first result. I recommend add "limit 1" in your sql.
  *
  * @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
  * @param paras the parameters of sql
  * @return Object[] if your sql has select more than one column, and it return Object if your sql
  *     has select only one column.
  */
 public static <T> T queryFirst(String sql, Object... paras) {
   return dbPro.queryFirst(sql, paras);
 }
Example #22
0
 /** @see #execute(String, ICallback) */
 public static Object execute(ICallback callback) {
   return dbPro.execute(callback);
 }
Example #23
0
 /** @see #batch(String, List, int) */
 public static int[] batch(List<String> sqlList, int batchSize) {
   return dbPro.batch(sqlList, batchSize);
 }
Example #24
0
 /**
  * @see #query(String, Object...)
  * @param sql an SQL statement
  */
 public static <T> List<T> query(String sql) {
   return dbPro.query(sql);
 }
Example #25
0
 /**
  * Execute sql query just return one column.
  *
  * @param <T> the type of the column that in your sql's select statement
  * @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
  * @param paras the parameters of sql
  * @return List<T>
  */
 public static <T> T queryColumn(String sql, Object... paras) {
   return dbPro.queryColumn(sql, paras);
 }
Example #26
0
 /**
  * Execute callback. It is useful when all the API can not satisfy your requirement.
  *
  * @param config the Config object
  * @param callback the ICallback interface
  */
 static Object execute(Config config, ICallback callback) {
   return dbPro.execute(config, callback);
 }
Example #27
0
 public static String queryStr(String sql, Object... paras) {
   return dbPro.queryStr(sql, paras);
 }
Example #28
0
 /**
  * Execute transaction.
  *
  * @param config the Config object
  * @param transactionLevel the transaction level
  * @param atom the atom operation
  * @return true if transaction executing succeed otherwise false
  */
 static boolean tx(Config config, int transactionLevel, IAtom atom) {
   return dbPro.tx(config, transactionLevel, atom);
 }
Example #29
0
 public static Integer queryInt(String sql, Object... paras) {
   return dbPro.queryInt(sql, paras);
 }
Example #30
0
 public static boolean tx(int transactionLevel, IAtom atom) {
   return dbPro.tx(transactionLevel, atom);
 }