Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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;
   }
 }
Beispiel #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);
 }
Beispiel #6
0
 /**
  * Execute transaction with default transaction level.
  *
  * @see #tx(int, IAtom)
  */
 public static boolean tx(IAtom atom) {
   return dbPro.tx(atom);
 }
Beispiel #7
0
 public static String queryStr(String sql) {
   return dbPro.queryStr(sql);
 }
Beispiel #8
0
 /**
  * @see #queryFirst(String, Object...)
  * @param sql an SQL statement
  */
 public static <T> T queryFirst(String sql) {
   return dbPro.queryFirst(sql);
 }
Beispiel #9
0
 public static <T> T queryColumn(String sql) {
   return dbPro.queryColumn(sql);
 }
Beispiel #10
0
 /** @see #batch(String, String, Object[][], int) */
 public static int[] batch(String sql, Object[][] paras, int batchSize) {
   return dbPro.batch(sql, paras, batchSize);
 }
Beispiel #11
0
 static <T> List<T> query(Config config, Connection conn, String sql, Object... paras)
     throws SQLException {
   return dbPro.query(config, conn, sql, paras);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #14
0
 /** @see #save(String, String, Record) */
 public static boolean save(String tableName, Record record) {
   return dbPro.save(tableName, record);
 }
Beispiel #15
0
 /** @see #query(String, String, Object...) */
 public static <T> List<T> query(String sql, Object... paras) {
   return dbPro.query(sql, paras);
 }
Beispiel #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);
 }
Beispiel #17
0
 /** @see #findFirstByCache(String, Object, String, Object...) */
 public static Record findFirstByCache(String cacheName, Object key, String sql) {
   return dbPro.findFirstByCache(cacheName, key, sql);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #22
0
 /** @see #execute(String, ICallback) */
 public static Object execute(ICallback callback) {
   return dbPro.execute(callback);
 }
Beispiel #23
0
 /** @see #batch(String, List, int) */
 public static int[] batch(List<String> sqlList, int batchSize) {
   return dbPro.batch(sqlList, batchSize);
 }
Beispiel #24
0
 /**
  * @see #query(String, Object...)
  * @param sql an SQL statement
  */
 public static <T> List<T> query(String sql) {
   return dbPro.query(sql);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #27
0
 public static String queryStr(String sql, Object... paras) {
   return dbPro.queryStr(sql, paras);
 }
Beispiel #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);
 }
Beispiel #29
0
 public static Integer queryInt(String sql, Object... paras) {
   return dbPro.queryInt(sql, paras);
 }
Beispiel #30
0
 public static boolean tx(int transactionLevel, IAtom atom) {
   return dbPro.tx(transactionLevel, atom);
 }