Mybatis 全表操作拦截器


/**
 * @author ybb
 * @Description 全表操作拦截器
 */

@Intercepts({
	@Signature(
		type= Executor.class,
		method="query",
		args={MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}
	),
	@Signature(
		type= Executor.class,
		method="query",
		args={MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}
	)
})
public class FullTableOperationInterceptor extends JsqlParserSupport implements Interceptor {

	public static final int MAX_PAGE_SIZE = 10000;

	public FullTableOperationInterceptor() {
	}

	protected void processSelect(Select select, int index, String sql, Object obj)throws Exception {
		PlainSelect  plainSelect = (PlainSelect) select.getSelectBody();
		Expression where = plainSelect.getWhere();
		if (where == null) {
			throw new Exception("Full table scan! sql has no 

猜你喜欢

转载自blog.csdn.net/tumu6889/article/details/126921510