开发者社区> 问答> 正文

是否支持cte语法啊

Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'WITH RECURSIVE ancestors AS ( ',expect WITH, actual WITH WITH

org.springframework.jdbc.UncategorizedSQLException:

Error querying database. Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'WITH RECURSIVE ancestors AS ( ',expect WITH, actual WITH WITH : WITH RECURSIVE ancestors AS ( SELECT * FROM org WHERE 1=1 AND deleted = 1

UNION SELECT f.* FROM org AS f, ancestors AS a WHERE f.id = a.parent_id ) SELECT * FROM ancestors;

The error may exist in file [D:\workspace\backend\security\moses\security-admin-provider\target\classes\mapper\OrgMapper.xml] The error may involve cn.vpclub.moses.security.admin.provider.storage.mapper.OrgMapper.selectAllChildren The error occurred while executing a query SQL: WITH RECURSIVE ancestors AS ( SELECT * FROM org WHERE 1=1 AND deleted = 1 UNION SELECT f.* FROM org AS f, ancestors AS a WHERE f.id = a.parent_id ) SELECT * FROM ancestors; Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'WITH RECURSIVE ancestors AS ( ',expect WITH, actual WITH WITH : WITH RECURSIVE ancestors AS ( SELECT * FROM org WHERE 1=1 AND deleted = 1

UNION SELECT f.* FROM org AS f, ancestors AS a WHERE f.id = a.parent_id ) SELECT * FROM ancestors;

; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; sql injection violation, syntax error: syntax error, error in :'WITH RECURSIVE ancestors AS ( ',expect WITH, actual WITH WITH : WITH RECURSIVE ancestors AS ( SELECT * FROM org WHERE 1=1 AND deleted = 1

UNION SELECT f.* FROM org AS f, ancestors AS a WHERE f.id = a.parent_id ) SELECT * FROM ancestors;; nested exception is java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'WITH RECURSIVE ancestors AS (

',expect WITH, actual WITH WITH : WITH RECURSIVE ancestors AS ( SELECT * FROM org WHERE 1=1 AND deleted = 1

UNION SELECT f.* FROM org AS f, ancestors AS a WHERE f.id = a.parent_id ) SELECT * FROM ancestors; at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447) at com.sun.proxy.$Proxy82.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:128) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) at com.sun.proxy.$Proxy88.selectAllChildren(Unknown Source) at cn.vpclub.moses.security.admin.provider.service.OrgService.page(OrgService.java:397) at cn.vpclub.moses.security.admin.provider.service.OrgService$$FastClassBySpringCGLIB$$7854e304.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) at cn.vpclub.moses.security.admin.provider.service.OrgService$$EnhancerBySpringCGLIB$$5fffcca2.page() at cn.vpclub.moses.security.admin.provider.rpc.OrgRpc.list(OrgRpc.java:101) at cn.vpclub.moses.security.admin.api.OrgServiceGrpc$MethodHandlers.invoke(OrgServiceGrpc.java:579) at io.grpc.stub.ServerCalls$1$1.onHalfClose(ServerCalls.java:148) at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:267) at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$2.runInContext(ServerImpl.java:573) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52) at io.grpc.internal.SerializeReentrantCallsDirectExecutor.execute(SerializeReentrantCallsDirectExecutor.java:64) at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener.halfClosed(ServerImpl.java:569) at io.grpc.inprocess.InProcessTransport$InProcessStream$InProcessClientStream.halfClose(InProcessTransport.java:551) at io.grpc.internal.ClientCallImpl.halfClose(ClientCallImpl.java:382) at io.grpc.ForwardingClientCall.halfClose(ForwardingClientCall.java:62) at io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:255) at io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:186) at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:132) at cn.vpclub.moses.security.admin.api.OrgServiceGrpc$OrgServiceBlockingStub.list(OrgServiceGrpc.java:411) at cn.vpclub.moses.security.admin.provider.app.OrgIntegrationTests.testListOrg(OrgIntegrationTests.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:205) at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:175) at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:217) at org.testng.internal.Invoker.invokeMethod(Invoker.java:641) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) at org.testng.TestRunner.privateRun(TestRunner.java:756) at org.testng.TestRunner.run(TestRunner.java:610) at org.testng.SuiteRunner.runTest(SuiteRunner.java:387) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) at org.testng.SuiteRunner.run(SuiteRunner.java:289) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) at org.testng.TestNG.runSuites(TestNG.java:1133) at org.testng.TestNG.run(TestNG.java:1104) at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Caused by: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'WITH RECURSIVE ancestors AS ( ',expect WITH, actual WITH WITH : WITH RECURSIVE ancestors AS ( SELECT * FROM org WHERE 1=1 AND deleted = 1

UNION SELECT f.* FROM org AS f, ancestors AS a WHERE f.id = a.parent_id ) SELECT * FROM ancestors; at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:724) at com.alibaba.druid.wall.WallFilter.connection_prepareStatement(WallFilter.java:252) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448) at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:928) at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:122) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448) at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:928) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:331) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:55) at com.sun.proxy.$Proxy113.prepareStatement(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:87) at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88) at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) at com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:401) at com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:374) at com.github.pagehelper.PageHelper.intercept(PageHelper.java:255) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy112.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434) ... 65 common frames omitted

Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'WITH RECURSIVE ancestors AS ( ',expect WITH, actual WITH WITH at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:239) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:431) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:148) at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:620) at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:574) at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:711) ... 106 common frames omitted

原提问者GitHub用户RobinsChens

展开
收起
山海行 2023-07-05 20:47:17 70 0
3 条回答
写回答
取消 提交回答
  • 支持的

    2023-07-30 14:35:10
    赞同 展开评论 打赏
  • 北京阿里云ACE会长

    Common Table Expression(CTE)语法是一种在SQL查询中定义临时命名结果集的方法。在Spring Boot中,如果您使用的是支持CTE语法的数据库,例如MySQL 8.0、PostgreSQL 8.4、Oracle 11g等,则可以在SQL查询中使用CTE语法。

    Spring Boot本身并不限制您使用哪种SQL语法,因为它主要是一个框架,可以与各种数据库和SQL语法进行集成。如果您需要使用CTE语法,只需要在SQL查询中使用WITH子句定义CTE,然后在查询中引用该CTE即可。

    2023-07-30 13:26:03
    赞同 展开评论 打赏
  • druid什么版本?升级到最新版本试试看 https://github.com/alibaba/druid/releases/tag/1.1.4

    原回答者GitHub用户wenshao

    2023-07-06 11:45:36
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载