public class DataChangeRecorderInnerInterceptor extends java.lang.Object implements InnerInterceptor
数据变动记录插件 默认会生成一条log,格式: ----------------------INSERT LOG------------------------------ { "tableName": "h2user", "operation": "insert", "recordStatus": "true", "changedData": [ { "LAST_UPDATED_DT": "null->2022-08-22 18:49:16.512", "TEST_ID": "null->1561666810058739714", "AGE": "null->THREE" } ], "cost(ms)": 0 }
* ----------------------UPDATE LOG------------------------------
{ "tableName": "h2user", "operation": "update", "recordStatus": "true", "changedData": [ { "TEST_ID": "102", "AGE": "2->THREE", "FIRSTNAME": "DOU.HAO->{\"json\":\"abc\"}", "LAST_UPDATED_DT": "null->2022-08-22 18:49:16.512" } ], "cost(ms)": 0 }
| 限定符和类型 | 类和说明 |
|---|---|
static class |
DataChangeRecorderInnerInterceptor.Columns2SelectItemsResult |
static class |
DataChangeRecorderInnerInterceptor.DataChangedRecord |
static class |
DataChangeRecorderInnerInterceptor.DataColumnChangeResult |
static class |
DataChangeRecorderInnerInterceptor.OperationResult |
static class |
DataChangeRecorderInnerInterceptor.OriginalDataObj |
| 限定符和类型 | 字段和说明 |
|---|---|
static java.lang.String |
IGNORED_TABLE_COLUMN_PROPERTIES |
protected org.slf4j.Logger |
logger |
| 构造器和说明 |
|---|
DataChangeRecorderInnerInterceptor() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected boolean |
allowProcess(java.lang.String sql)
判断哪些SQL需要处理
默认INSERT/UPDATE/DELETE语句
|
void |
beforePrepare(org.apache.ibatis.executor.statement.StatementHandler sh,
java.sql.Connection connection,
java.lang.Integer transactionTimeout)
StatementHandler.prepare(Connection, Integer) 操作前置处理
改改sql啥的 |
protected void |
dealOperationResult(DataChangeRecorderInnerInterceptor.OperationResult operationResult)
处理数据更新结果,默认打印
|
DataChangeRecorderInnerInterceptor.OperationResult |
processDelete(net.sf.jsqlparser.statement.delete.Delete deleteStmt,
org.apache.ibatis.mapping.MappedStatement mappedStatement,
org.apache.ibatis.mapping.BoundSql boundSql,
java.sql.Connection connection) |
DataChangeRecorderInnerInterceptor.OperationResult |
processInsert(net.sf.jsqlparser.statement.insert.Insert insertStmt,
org.apache.ibatis.mapping.BoundSql boundSql) |
DataChangeRecorderInnerInterceptor.OperationResult |
processUpdate(net.sf.jsqlparser.statement.update.Update updateStmt,
org.apache.ibatis.mapping.MappedStatement mappedStatement,
org.apache.ibatis.mapping.BoundSql boundSql,
java.sql.Connection connection) |
void |
setProperties(java.util.Properties properties)
ignoredColumns = TABLE_NAME1.COLUMN1,COLUMN2; TABLE2.COLUMN1,COLUMN2; TABLE3.*; *.COLUMN1,COLUMN2
多个表用分号分隔
TABLE_NAME1.COLUMN1,COLUMN2 : 表示忽略这个表的这2个字段
TABLE3.*: 表示忽略这张表的INSERT/UPDATE,delete暂时还保留
*.COLUMN1,COLUMN2:表示所有表的这个2个字段名都忽略
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbeforeGetBoundSql, beforeQuery, beforeUpdate, willDoQuery, willDoUpdateprotected final org.slf4j.Logger logger
public static final java.lang.String IGNORED_TABLE_COLUMN_PROPERTIES
public void beforePrepare(org.apache.ibatis.executor.statement.StatementHandler sh,
java.sql.Connection connection,
java.lang.Integer transactionTimeout)
InnerInterceptorStatementHandler.prepare(Connection, Integer) 操作前置处理
改改sql啥的
beforePrepare 在接口中 InnerInterceptorsh - StatementHandler(可能是代理对象)connection - ConnectiontransactionTimeout - transactionTimeoutprotected boolean allowProcess(java.lang.String sql)
sql - protected void dealOperationResult(DataChangeRecorderInnerInterceptor.OperationResult operationResult)
operationResult - public DataChangeRecorderInnerInterceptor.OperationResult processInsert(net.sf.jsqlparser.statement.insert.Insert insertStmt, org.apache.ibatis.mapping.BoundSql boundSql)
public DataChangeRecorderInnerInterceptor.OperationResult processUpdate(net.sf.jsqlparser.statement.update.Update updateStmt, org.apache.ibatis.mapping.MappedStatement mappedStatement, org.apache.ibatis.mapping.BoundSql boundSql, java.sql.Connection connection)
public DataChangeRecorderInnerInterceptor.OperationResult processDelete(net.sf.jsqlparser.statement.delete.Delete deleteStmt, org.apache.ibatis.mapping.MappedStatement mappedStatement, org.apache.ibatis.mapping.BoundSql boundSql, java.sql.Connection connection)
public void setProperties(java.util.Properties properties)
setProperties 在接口中 InnerInterceptorproperties -