程序包 cn.myafx.data

接口 IDatabase

所有超级接口:
AutoCloseable
所有已知实现类:
Database

public interface IDatabase extends AutoCloseable
database
  • 方法详细资料

    • isClose

      boolean isClose()
      is close
      返回:
      boolean
    • isTransaction

      boolean isTransaction()
      is transaction
      返回:
      boolean
    • open

      void open() throws Exception
      open
      抛出:
      Exception
    • beginTransaction

      void beginTransaction() throws Exception
      begin transaction
      抛出:
      Exception
    • beginTransaction

      void beginTransaction(IsolationLevel level) throws Exception
      begin transaction
      参数:
      level - IsolationLevel
      抛出:
      Exception
    • commit

      void commit() throws Exception
      commit
      抛出:
      Exception
    • rollback

      void rollback() throws Exception
      rollback
      抛出:
      Exception
    • execute

      int execute(String sql, Object... param) throws Exception
      execute sql
      参数:
      sql - update/delete/insert; param: ? or ${name} or #{name}
      param - update tb set name = ? where id = ? param is Object[]; update tb set name = ${mame} where id = ${id} param is model or Map<String, Object>
      返回:
      int
      抛出:
      Exception
    • queryOne

      <T> T queryOne(String sql, Class<T> clazz, Object... param) throws Exception
      query first model
      类型参数:
      T - model
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      clazz - T.class
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      first model
      抛出:
      Exception
    • queryList

      <T> List<T> queryList(String sql, Class<T> clazz, Object... param) throws Exception
      query List
      类型参数:
      T - model
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      clazz - T.class
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      List
      抛出:
      Exception
    • queryOneMap

      Map<String,Object> queryOneMap(String sql, Object... param) throws Exception
      query first Map<String, Object>
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      first Map<String, Object>
      抛出:
      Exception
    • queryListMap

      List<Map<String,Object>> queryListMap(String sql, Object... param) throws Exception
      query List Map<String, Object>
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      List Map String, Object
      抛出:
      Exception
    • get

      <TModel extends Model> TModel get(Class<TModel> clazz, Map<String,Object> param) throws Exception
      get first model
      类型参数:
      TModel - Model
      参数:
      clazz - TModel.class
      param - where param
      返回:
      first Model
      抛出:
      Exception
    • getList

      <TModel extends Model> List<TModel> getList(Class<TModel> clazz, Map<String,Object> param) throws Exception
      get List model
      类型参数:
      TModel - Model
      参数:
      clazz - TModel.class
      param - where param
      返回:
      List Model
      抛出:
      Exception
    • add

      int add(String table, Map<String,Object> param) throws Exception
      add row
      参数:
      table - table name
      param - insert param
      返回:
      int
      抛出:
      Exception
    • add

      <TModel extends Model> int add(TModel m, String[] ignore) throws Exception
      add model
      类型参数:
      TModel - Model
      参数:
      m - model
      ignore - ignore model property name
      返回:
      int
      抛出:
      Exception
    • update

      int update(String table, Map<String,Object> setParam, Map<String,Object> whereParam) throws Exception
      update
      参数:
      table - table name
      setParam - update param
      whereParam - where param
      返回:
      int
      抛出:
      Exception
    • update

      <TModel extends Model> int update(Class<TModel> clazz, Map<String,Object> setParam, Map<String,Object> whereParam) throws Exception
      update
      类型参数:
      TModel - Model
      参数:
      clazz - Model.class
      setParam - update param
      whereParam - where param
      返回:
      int
      抛出:
      Exception
    • delete

      int delete(String table, Map<String,Object> whereParam) throws Exception
      delete
      参数:
      table - table name
      whereParam - where param
      返回:
      int
      抛出:
      Exception
    • delete

      <TModel extends Model> int delete(Class<TModel> clazz, Map<String,Object> whereParam) throws Exception
      delete
      类型参数:
      TModel - Model
      参数:
      clazz - Model.class
      whereParam - where param
      返回:
      int
      抛出:
      Exception