首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

Mybatis【11】-- Mybatis Mapper动态代理怎么写?

定义数据库查询的接口,里面每一个接口的名字很重要,需要和mapper里面每一条sql对应起来: 定义mapper文件(namespace是接口的全限定类名): 那我们在使用的时候,需要使用sqlSession.getMapper...打一个断点在sqlSession.getMapper()方法上: 我们可以看到执行下面的接口方法(接口SqlSession的方法) T getMapper(Class var1); 这是一个接口...我们可以看到实现接口的有两个类,一个是DefaultSqlSession,一个是SqlSessionManager,我们需要看的是DefaultSqlSession下面的接口: public T getMapper...跟进去,这是使用mapper注册器对象的getMapper()方法,将当前的sqlSession对象传递进去: public T getMapper(Class type, SqlSession...sqlSession) { return mapperRegistry.getMapper(type, sqlSession); } 我们跟进去源码,可以发现里面使用knownMappers.get

58210

Mybatis【11】-- Mybatis Mapper动态代理怎么写?

里面每一条sql对应起来: [91175625.jpg] 定义mapper文件(namespace是接口的全限定类名): [80749780.jpg] 那我们在使用的时候,需要使用sqlSession.getMapper...打一个断点在sqlSession.getMapper()方法上: [99377126.jpg] 我们可以看到执行下面的接口方法(接口SqlSession的方法) T getMapper(Class...(Class type) { return this.configuration.getMapper(type, this); } 我们知道,在创建sqlsession的时候,confiiguration...跟进去,这是使用mapper注册器对象的getMapper()方法,将当前的sqlSession对象传递进去: public T getMapper(Class type, SqlSession...sqlSession) { return mapperRegistry.getMapper(type, sqlSession); } 我们跟进去源码,可以发现里面使用knownMappers.get

29800
领券