@Override
    public Object intercept(final Invocation invocation) throws Throwable {
        StatementHandler statementHandler = (StatementHandler) invocation.getTarget();

        //Elegant access to object properties through MetaObject, here is access to the properties of statementHandler;
        //MetaObject is an object provided by Mybatis for easy and elegant access to object properties,
        // through which you can simplify the code, no need to try/catch various reflect exceptions,
        // while it supports the operation of JavaBean, Collection, Map three types of object operations.
        // MetaObject metaObject = MetaObject
        //        .forObject(statementHandler, SystemMetaObject.DEFAULT_OBJECT_FACTORY, SystemMetaObject.DEFAULT_OBJECT_WRAPPER_FACTORY,
        //                new DefaultReflectorFactory());
        //First intercept to RoutingStatementHandler, there is a StatementHandler type delegate variable,
        // its implementation class is BaseStatementHandler, and then to the BaseStatementHandler member variable mappedStatement

        // MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
        // String id = mappedStatement.getId(); mapper method full path
        // String sqlCommandType = mappedStatement.getSqlCommandType().toString();  sql method eg: insert update delete select
        BoundSql boundSql = statementHandler.getBoundSql();
        // get original sql file
        // reflect modify sql file
        Field field = boundSql.getClass().getDeclaredField("sql");
        field.setAccessible(true);
        // replace desc and true
        String replaceSql = boundSql.getSql().toLowerCase()
                .replace("`desc`", "\"desc\"")
                .replace("true", "'true'");
        // replace`
        replaceSql = replaceSql.replace("`", "");
        // replace resource
        if (replaceSql.contains("resource")) {
            replaceSql = replaceSql.replace("into resource", "into \"resource\"")
                    .replace("from resource", "from \"resource\"")
                    .replace("update resource", "update \"resource\"");
        }
        // replace batch insert into
        if (replaceSql.contains("insert into") && replaceSql.split("\\(").length > 3) {
            replaceSql = replaceSql.replaceAll("\r|\n|\\s", "")
                    .replace("insertinto", "insert into ")
                    .replace("values", " SELECT * FROM (")
                    .replace("(?", " SELECT ?")
                    .replace("),", " FROM dual UNION ALL")
                    .replace("?)", " ? FROM dual)");
        }

        // replace limit 1
        if (replaceSql.contains("select")) {
            if (replaceSql.contains("where")) {
                replaceSql = replaceSql.replace("limit 1", "and rownum = 1");
            } else {
                replaceSql = replaceSql.replace("limit 1", "where rownum = 1");
            }
        }
        field.set(boundSql, replaceSql);

        return invocation.proceed();
    }
@Test
    public void interceptTest() {
        final OracleSQLPrepareInterceptor oracleSQLPrepareInterceptor = new OracleSQLPrepareInterceptor();
        final Invocation invocation = mock(Invocation.class);
        final StatementHandler statementHandler = mock(StatementHandler.class);
        when(invocation.getTarget()).thenReturn(statementHandler);
        final BoundSql boundSql = mock(BoundSql.class);
        when(statementHandler.getBoundSql()).thenReturn(boundSql);
        when(boundSql.getSql()).thenReturn("select * from users where name = 1 limit 1");
        Assertions.assertDoesNotThrow(() -> oracleSQLPrepareInterceptor.intercept(invocation));
        when(boundSql.getSql()).thenReturn("select * from users limit 1");
        Assertions.assertDoesNotThrow(() -> oracleSQLPrepareInterceptor.intercept(invocation));
        when(boundSql.getSql()).thenReturn("INSERT INTO `users` VALUES ('1529402613204172899', '34')('1529402613204172899', '34')('1529402613204172899', '34'); ");
        Assertions.assertDoesNotThrow(() -> oracleSQLPrepareInterceptor.intercept(invocation));
        when(boundSql.getSql()).thenReturn("INSERT INTO `resource` VALUES ('1529402613204172899', '34')('1529402613204172899', '34')('1529402613204172899', '34'); ");
        Assertions.assertDoesNotThrow(() -> oracleSQLPrepareInterceptor.intercept(invocation));
    }