/**
* SQL 监听器
* <p>
* 对不含 where 的 update 语句进行拦截,防止批量误操作
*/publicclassQueryFilterextendsSqlExcuteListener{privatestaticfinallong serialVersionUID =-3172666378145934837L;@OverridepublicvoidrenderEnd(ExecuteContext ctx){super.renderEnd(ctx);if(ctx.sql().matches("^(?i:(UPDATE|DELETE)(?!.* WHERE ).*)$")){thrownewDeleteOrUpdateWithoutWhereException();}}privateclassDeleteOrUpdateWithoutWhereExceptionextendsRuntimeException{privatestaticfinallong serialVersionUID =1263216828793967446L;@Overridepublic String getMessage(){return"Delete or update operation without where cannot be executed.";}}}