@Intercepts({@Signature( type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class} )}) @Component public class MyInterceptorForMybatis implements Interceptor { private final Logger logger = LoggerFactory.getLogger(MyInterceptorForMybatis.class); public MyInterceptorForMybatis() { } public Object intercept(Invocation invocation) throws Throwable { Object[] args = invocation.getArgs(); MappedStatement statement = (MappedStatement)args[0]; BoundSql boundSql = statement.getBoundSql(args[1]); String sql = boundSql.getSql(); Object rs = modifyLikeSql(sql, args[1], boundSql); if (rs instanceof String) { args[1] = rs; } return invocation.proceed(); } public Object plugin(Object target) { return Plugin.wrap(target, this); } public void
mybatis 拦截 query like 子句 转义% _ \
最新推荐文章于 2023-05-11 20:24:56 发布