public abstract class BaseDAO extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected Connection |
objConn |
| 构造器和说明 |
|---|
BaseDAO() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
BlobToBytes(Blob blob) |
protected String |
buildSQLSelect(String tableOrViewOrSQLView,
String whereString,
String orderBy) |
static String |
clobToString(Clob clob) |
void |
closeConnection() |
int |
executeUpdate(String sql)
【V1.0】同executeUpdate(String sql, List
|
int |
executeUpdate(String sql,
List<Object> pramValues)
【V1.0】执行一条DML的SQL。
|
void |
executeUpdateBatch(String sql,
List<List<Object>> paramsValuesArray)
【V1.0】批量插入、更新数据。
|
void |
executeUpdateBatch(String sql,
List<List<Object>> paramsValuesArray,
int batch_page_size,
boolean batch_isInBatchCommit)
【V1.0】批量插入、更新数据。
|
abstract Connection |
getConnection()
由子类实现获取数据库链接的功能
|
abstract String |
getDBType()
由子类指定数据库类型。
|
int |
getIntPkIdByConfigTable(String config_table_name,
String table_name)
从配置表中获取主键id。
|
<T> T |
getOneEntity(String tableOrViewOrSQLView,
String whereString,
Class<T> tClass) |
com.alibaba.fastjson2.JSONObject |
getOneJson(String tableOrViewOrSQLView,
String whereString) |
boolean |
getPrintSql(boolean isPrint) |
ResultSet |
getResultSet(Connection objConn,
String sql)
【V1.0】执行一条查询SQL语句。
|
ResultSet |
getResultSet(Connection objConn,
String sql,
List paramValues)
【V1.0】执行一条查询SQL语句。
|
int |
getRowCount(String tableOrViewName,
String whereString) |
long |
getRowCountLong(String tableOrViewName,
String whereString) |
void |
printColumnInfo(String tableOrViewName)
查看jdbc和rmdb这间的映射关系。
|
com.alibaba.fastjson2.JSONArray |
query(String sql) |
com.alibaba.fastjson2.JSONArray |
query(String sql,
List pramValues) |
com.alibaba.fastjson2.JSONArray |
query(String tableOrViewOrSQLView,
String whereString,
String orderBy) |
<T> List |
queryPageDataEntityList(String tableOrViewOrSQLView,
String whereString,
String orderBy,
int pageNo,
int pageSize,
Class<T> objectClass) |
com.alibaba.fastjson2.JSONArray |
queryPageDataJsonArray(String tableOrViewOrSQLView,
String whereString,
String orderBy,
int pageNo,
int pageSize) |
PageInfo |
queryPageInfo(String tableOrViewOrSQLView,
String whereString,
String orderBy,
int pageNo,
int pageSize) |
<T> List |
queryToList(String tableOrViewOrSQLView,
String whereString,
String orderBy,
Class<T> objectClass) |
List<HashMap<String,Object>> |
queryToMap(String tableOrViewOrSQLView,
String whereString,
String orderBy) |
static com.alibaba.fastjson2.JSONArray |
resultSetToJSONArray(ResultSet rs) |
List<HashMap<String,Object>> |
resultSetToMapList(ResultSet rs) |
void |
setPrintSql(boolean isPrint) |
protected Connection objConn
public void setPrintSql(boolean isPrint)
public boolean getPrintSql(boolean isPrint)
public int getIntPkIdByConfigTable(String config_table_name, String table_name)
config_table_name - 如:assist_pk_infotable_name - 如:sys_user。public abstract Connection getConnection() throws Exception
Exceptionpublic abstract String getDBType()
public void closeConnection()
public int executeUpdate(String sql)
sql - 要执行的sql。public int executeUpdate(String sql, List<Object> pramValues)
sql - 要执行的sql。pramValues - 值的数组。表示sql对应的参数,其中数组中的每个值表示对应列的值。如果没有参数,传入null。public void executeUpdateBatch(String sql, List<List<Object>> paramsValuesArray, int batch_page_size, boolean batch_isInBatchCommit)
sql - 要执行的sql。paramsValuesArray - 数组<值数组>,表示sql对应的参数。每个值数组表示要插入/更新的一条数据的值。batch_page_size - 每批次的数量。batch_isInBatchCommit - 是否分批提交。
ture - 启用分批提交,会忽略某一批次错误,继续下一次处理;
false - 整个数据最后一起提交,要么全成功、要么全失败。
以45条数据、每次插入10条为例:true-如果第3批次失败,则只入库前二次的20条数据,且会继续执行后续批次的操作;false-如果第3批次失败,则全部回滚,且不执行后续批次的操作。public void executeUpdateBatch(String sql, List<List<Object>> paramsValuesArray)
sql - 要执行的sql。paramsValuesArray - 数组<值数组>,表示sql对应的参数。每个值数组表示要插入/更新的一条数据的值。public ResultSet getResultSet(Connection objConn, String sql)
sql - 要执行的sql。public ResultSet getResultSet(Connection objConn, String sql, List paramValues)
sql - 要执行的sql。paramValues - 值的数组。表示sql对应的参数,其中数组中的每个值表示对应列的值。如果没有参数,传入null。public void printColumnInfo(String tableOrViewName)
tableOrViewName - Exceptionprotected String buildSQLSelect(String tableOrViewOrSQLView, String whereString, String orderBy)
public com.alibaba.fastjson2.JSONArray query(String tableOrViewOrSQLView, String whereString, String orderBy)
public List<HashMap<String,Object>> queryToMap(String tableOrViewOrSQLView, String whereString, String orderBy)
public <T> List queryToList(String tableOrViewOrSQLView, String whereString, String orderBy, Class<T> objectClass)
public com.alibaba.fastjson2.JSONObject getOneJson(String tableOrViewOrSQLView, String whereString)
public <T> T getOneEntity(String tableOrViewOrSQLView, String whereString, Class<T> tClass)
public com.alibaba.fastjson2.JSONArray query(String sql)
public com.alibaba.fastjson2.JSONArray queryPageDataJsonArray(String tableOrViewOrSQLView, String whereString, String orderBy, int pageNo, int pageSize)
public <T> List queryPageDataEntityList(String tableOrViewOrSQLView, String whereString, String orderBy, int pageNo, int pageSize, Class<T> objectClass)
public PageInfo queryPageInfo(String tableOrViewOrSQLView, String whereString, String orderBy, int pageNo, int pageSize)
public List<HashMap<String,Object>> resultSetToMapList(ResultSet rs) throws Exception
Exceptionpublic static com.alibaba.fastjson2.JSONArray resultSetToJSONArray(ResultSet rs) throws Exception
Exceptionpublic static String clobToString(Clob clob) throws SQLException, IOException
Copyright © 2024. All rights reserved.