mybatis的拦截器如何才能得到Connection?
本文介绍了mybatis的拦截器如何才能得到Connection?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
自己写了个mybatis的拦截器,拦截方法注释如下:
@Intercepts(value = {
@Signature(type = Executor.class,
method = "update",
args = {MappedStatement.class,Object.class})
})
在这种方式下不知道如何才能得到Connection?我看到用prepare拦截的方式是可以得到的,就是update方式拦截网上都没找到怎么拿到Connection。
解决方案
mybatis只能拦截一下几个接口的方法
Executor (update, query, flushStatements, commit, rollback, getTransaction, close, isClosed)
ParameterHandler (getParameterObject, setParameters)
ResultSetHandler (handleResultSets, handleOutputParameters)
StatementHandler (prepare, parameterize, batch, update, query)
在以上方法中只有StatementHandler#prepare()
可以得到connection
这篇关于mybatis的拦截器如何才能得到Connection?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文