/** @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); }
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); }
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; } }
/** @see #findByCache(String, Object, String, Object...) */ public static List<Record> findByCache(String cacheName, Object key, String sql) { return dbPro.findByCache(cacheName, key, sql); }
/** * Execute transaction with default transaction level. * * @see #tx(int, IAtom) */ public static boolean tx(IAtom atom) { return dbPro.tx(atom); }
public static String queryStr(String sql) { return dbPro.queryStr(sql); }
/** * @see #queryFirst(String, Object...) * @param sql an SQL statement */ public static <T> T queryFirst(String sql) { return dbPro.queryFirst(sql); }
public static <T> T queryColumn(String sql) { return dbPro.queryColumn(sql); }
/** @see #batch(String, String, Object[][], int) */ public static int[] batch(String sql, Object[][] paras, int batchSize) { return dbPro.batch(sql, paras, batchSize); }
static <T> List<T> query(Config config, Connection conn, String sql, Object... paras) throws SQLException { return dbPro.query(config, conn, sql, paras); }
static boolean update( Config config, Connection conn, String tableName, String primaryKey, Record record) throws SQLException { return dbPro.update(config, conn, tableName, primaryKey, record); }
/** * 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); }
/** @see #save(String, String, Record) */ public static boolean save(String tableName, Record record) { return dbPro.save(tableName, record); }
/** @see #query(String, String, Object...) */ public static <T> List<T> query(String sql, Object... paras) { return dbPro.query(sql, paras); }
/** @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); }
/** @see #findFirstByCache(String, Object, String, Object...) */ public static Record findFirstByCache(String cacheName, Object key, String sql) { return dbPro.findFirstByCache(cacheName, key, sql); }
/** @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); }
/** * 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); }
/** * * * <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); }
/** * 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); }
/** @see #execute(String, ICallback) */ public static Object execute(ICallback callback) { return dbPro.execute(callback); }
/** @see #batch(String, List, int) */ public static int[] batch(List<String> sqlList, int batchSize) { return dbPro.batch(sqlList, batchSize); }
/** * @see #query(String, Object...) * @param sql an SQL statement */ public static <T> List<T> query(String sql) { return dbPro.query(sql); }
/** * 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); }
/** * 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); }
public static String queryStr(String sql, Object... paras) { return dbPro.queryStr(sql, paras); }
/** * 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); }
public static Integer queryInt(String sql, Object... paras) { return dbPro.queryInt(sql, paras); }
public static boolean tx(int transactionLevel, IAtom atom) { return dbPro.tx(transactionLevel, atom); }