MySQL8支持递归语句WITH RECURSIVE,直接使用jfinal现有配置会出现以下错误:
Sql: WITH RECURSIVE unit_path (id, pId) AS ( SELECT unit.id, unit.pId FROM unit WHERE unit.id = 1 UNION ALL SELECT unit.id, unit.pId FROM unit INNER JOIN unit_path ON unit.pid = unit_path.id ) SELECT * FROM unit_path;
2019-02-23 21:29:06
[ERROR]-[Thread: XNIO-5 task-2]-[com.jfinal.core.ActionHandler.handle()]: /rescue/worker/test
com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'WITH RECURSIVE unit_path (id, ',expect WITH, actual WITH WITH : WITH RECURSIVE unit_path (id, pId) AS ( SELECT unit.id, unit.pId FROM unit WHERE unit.id = 1 UNION ALL SELECT unit.id, unit.pId FROM unit INNER JOIN unit_path ON unit.pid = unit_path.id ) SELECT * FROM unit_path;
at com.jfinal.plugin.activerecord.Model.find(Model.java:662)
Caused by: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'WITH RECURSIVE unit_path (id, ',expect WITH, actual WITH WITH : WITH RECURSIVE unit_path (id, pId) AS ( SELECT unit.id, unit.pId FROM unit WHERE unit.id = 1 UNION ALL SELECT unit.id, unit.pId FROM unit INNER JOIN unit_path ON unit.pid = unit_path.id ) SELECT * FROM unit_path;
at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:725)
看错误提示,感觉是druid做了过滤。
据波总提示,在JFinalConfig找到以下语句:
druidPlugin.addFilter(wallFilter);
注释掉即可。