All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jn.sqlhelper.mybatis.plugins.ExecutorInvocationSinkHandler Maven / Gradle / Ivy

There is a newer version: 5.0.9
Show newest version
package com.jn.sqlhelper.mybatis.plugins;

import com.jn.langx.pipeline.AbstractHandler;
import com.jn.langx.pipeline.HandlerContext;
import com.jn.langx.util.Objs;
import org.apache.ibatis.plugin.Invocation;

public class ExecutorInvocationSinkHandler extends AbstractHandler {
    @Override
    public void inbound(HandlerContext ctx) throws Throwable {
        ExecutorInvocation executorInvocation = (ExecutorInvocation) ctx.getPipeline().getTarget();
        Invocation invocation = executorInvocation.getInvocation();
        String method = executorInvocation.getMethodName();
        if (!method.equals("query")) {
            executorInvocation.setResult(invocation.proceed());
        } else {
            if (executorInvocation.isBoundSqlChanged() && Objs.isNotNull(executorInvocation.getBoundSql())) {
                executorInvocation.setResult(executorInvocation.getExecutor().query(executorInvocation.getMappedStatement(), executorInvocation.getParameter(), executorInvocation.getRowBounds(), executorInvocation.getResultHandler(), executorInvocation.getCacheKey(), executorInvocation.getBoundSql()));
            } else {
                executorInvocation.setResult(invocation.proceed());
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy