Package org.aoju.bus.starter.mapper
Class IllegalSqlHandler
java.lang.Object
org.aoju.bus.mapper.handler.AbstractSqlHandler
org.aoju.bus.starter.mapper.AbstractSqlParserHandler
org.aoju.bus.starter.mapper.IllegalSqlHandler
- All Implemented Interfaces:
org.aoju.bus.mapper.handler.SQLHandler,org.apache.ibatis.plugin.Interceptor
@Intercepts(@Signature(type=org.apache.ibatis.executor.statement.StatementHandler.class,method="prepare",args={Connection.class,Integer.class}))
public class IllegalSqlHandler
extends AbstractSqlParserHandler
implements org.apache.ibatis.plugin.Interceptor
由于开发人员水平参差不齐,即使订了开发规范很多人也不遵守
SQL是影响系统性能最重要的因素,所以拦截掉垃圾SQL语句
拦截SQL类型的场景
1.必须使用到索引,包含left jion连接字段,符合索引最左原则
必须使用索引好处,
1.1 如果因为动态SQL,bug导致update的where条件没有带上,全表更新上万条数据
1.2 如果检查到使用了索引,SQL性能基本不会太差
2.SQL尽量单表执行,有查询left jion的语句,必须在注释里面允许该SQL运行,否则会被拦截
SQL尽量单表执行的好处
2.1 查询条件简单、易于开理解和维护;
2.2 扩展性极强;(可为分库分表做准备)
2.3 缓存利用率高;
2.在字段上使用函数
3.where条件为空
4.where条件使用了 !=
5.where条件使用了 not 关键字
6.where条件使用了 or 关键字
7.where条件使用了 使用子查询
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
Fields inherited from class org.aoju.bus.mapper.handler.AbstractSqlHandler
DELEGATE_BOUNDSQL, DELEGATE_BOUNDSQL_SQL, DELEGATE_MAPPEDSTATEMENT, MAPPEDSTATEMENT -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.aoju.bus.starter.mapper.AbstractSqlParserHandler
allowProcess, doFilter, parser, processDelete, processInsert, processParser, processSelectBody, processUpdateMethods inherited from class org.aoju.bus.mapper.handler.AbstractSqlHandler
getMappedStatement, getMappedStatement, getSqlParserInfo, realTargetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.ibatis.plugin.Interceptor
setPropertiesMethods inherited from interface org.aoju.bus.mapper.handler.SQLHandler
afterCompletion, postHandle, preHandle
-
Constructor Details
-
IllegalSqlHandler
public IllegalSqlHandler()
-
-
Method Details
-
intercept
-
plugin
-