Mybatis SqlSessionTemplate 源码解析

Mybatis SqlSessionTemplate 源码解析

mybatis如何根据mapper接口生成其实现类

在使用Mybatis与Spring集成的时候我们使用的SqlSession实际上是用到了SqlSessionTemplate 这个类。

SqlSessionTemplate代理类实现SqlSession接口,定义了方法拦截器,如果调用代理类实例中实现SqlSession接口定义的方法,该调用则被导向SqlSessionInterceptor的invoke方法,invoke方法中包括了获取SqlSession和关闭SqlSession的方法,获取方法中已经保证了线程安全性

你可能感兴趣的:(Mybatis SqlSessionTemplate 源码解析)