当前位置:   article > 正文

mybatis打印执行的sql语句_tk.mybatis打印出执行了哪些sql

tk.mybatis打印出执行了哪些sql
  1. @Slf4j
  2. @Intercepts({
  3. @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})
  4. })
  5. public class MyPlugin implements Interceptor {
  6. Transaction transaction;
  7. //方法拦截
  8. @Override
  9. public Object intercept(Invocation invocation) throws Throwable {
  10. //通过StatementHandler获取执行的sql
  11. StatementHandler executor = (StatementHandler) invocation.getTarget();
  12. ParameterHandler parameterHandler = executor.getParameterHandler();
  13. parameterHandler.getParameterObject();
  14. BoundSql boundSql = executor.getBoundSql();
  15. List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  16. if (!CollectionUtils.isEmpty(parameterMappings)) {
  17. ParameterMapping parameterMapping = parameterMappings.get(0);
  18. Class clazz = parameterMapping.getClass();
  19. Field field 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/940285
推荐阅读
相关标签
  

闽ICP备14008679号