{"record":{"id":"ef64d6f0cfaa9680","repo":"baomidou/mybatis-plus","slug":"table-name-processing-failed-ef64d6","errorCode":null,"errorMessage":"Table name processing failed : ","messagePattern":"Table name processing failed : ","errorType":"exception","errorClass":"MybatisPlusException","httpStatus":null,"severity":"error","filePath":"mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/DynamicTableNameJsqlParserInnerInterceptor.java","lineNumber":86,"sourceCode":"            return statement.toString();\n        } catch (Exception exception) {\n            return handleFallback(unsupported, sql, exception);\n        }\n    }\n\n    private String handleFallback(boolean unsupported, String sql, Exception originalException) {\n        Exception exception = originalException;\n        if (!unsupported || shouldFallback) {\n            try {\n                return super.processTableName(sql);\n            } catch (Exception e) {\n                exception = e;\n            }\n        }\n        if (ignoreException) {\n            return sql;\n        }\n        throw new MybatisPlusException(\"Table name processing failed : \", exception);\n    }\n\n}\n","sourceCodeStart":68,"sourceCodeEnd":90,"githubUrl":"https://github.com/baomidou/mybatis-plus/blob/bf67d907478c724120bf76292da54abf9e73c2b3/mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/DynamicTableNameJsqlParserInnerInterceptor.java#L68-L90","documentation":"Thrown by DynamicTableNameJsqlParserInnerInterceptor when table-name rewriting fails at both layers: JSqlParser could not process the SQL (or produced an UnsupportedStatement whose fallback also failed), the parent DynamicTableNameInnerInterceptor regex/AST-based processing threw, and ignoreException is false (default). It wraps the last underlying exception, so the real cause (usually a JSQLParser parse error) is in the cause chain.","triggerScenarios":"Executing SQL that JSqlParser cannot parse (vendor-specific syntax like clickhouse/pg extensions, malformed SQL) or an UnsupportedStatement while a DynamicTableNameJsqlParserInnerInterceptor is in the interceptor chain, with default settings (shouldFallback=true already tried, ignoreException=false).","commonSituations":"Dialect-specific SQL (e.g. PostgreSQL 'RETURNING', MySQL hints, stored procedure calls) routed through dynamic table name rewriting; after upgrading mybatis-plus/jsqlparser where previously-parsed syntax now fails; custom SQL built by string concatenation that is not valid SQL.","solutions":["Inspect the wrapped cause (e.getCause()) to find the exact JSqlParser error position and fix the SQL syntax","Set ignoreException=true on the interceptor so unparseable SQL passes through unrewritten (accepting that the table name is not replaced for that statement)","Since shouldFallback defaults to true, verify the failure is a genuine parse error in the parent too; if the parent's TableNameParser fails on a false positive, simplify the SQL","Extract vendor-specific statements out of the intercepted mapper so the interceptor never sees them"],"exampleFix":"// before\nDynamicTableNameJsqlParserInnerInterceptor interceptor = new DynamicTableNameJsqlParserInnerInterceptor(handler);\n// after (tolerate unparseable SQL, skip rewriting for it)\nDynamicTableNameJsqlParserInnerInterceptor interceptor = new DynamicTableNameJsqlParserInnerInterceptor(handler);\ninterceptor.setIgnoreException(true);","handlingStrategy":"try-catch","validationCode":"// Pre-parse SQL before it reaches the dynamic-table-name interceptor\ntry {\n    Statement st = JsqlParserGlobal.parse(sql);\n    if (st instanceof UnsupportedStatement) {\n        LOGGER.warn(\"SQL unsupported by JSqlParser, will fall through: {}\", sql);\n    }\n} catch (Exception e) {\n    throw new IllegalArgumentException(\"SQL unparseable by JSqlParser: \" + sql, e);\n}","typeGuard":"static boolean isParseableByJsqlParser(String sql) {\n    try { JsqlParserGlobal.parse(sql); return true; }\n    catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n    return mapper.insertSpecialDialectSql(entity);\n} catch (MybatisPlusException e) {\n    if (\"Table name processing failed : \".equals(e.getMessage())) {\n        // either route around the interceptor or log & set ignoreException=true\n        LOGGER.error(\"Dynamic table name rewrite failed\", e.getCause());\n        throw e;\n    }\n    throw e;\n}","preventionTips":["Keep intercepted SQL within JSqlParser-supported dialect syntax","Consider interceptor.setIgnoreException(true) in environments where unparseable SQL must still run","Always inspect getCause() — the real JSqlParser error position is there, not in the message"],"tags":["mybatis-plus","jsqlparser","dynamic-table-name","sql-parsing"],"backgroundTag":null,"analyzedSha":"bf67d907478c724120bf76292da54abf9e73c2b3","analyzedAt":"2026-08-14T15:17:09.543Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}