💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ### mappedStatement 对应xml文件中的某一sql节点的封装 ![](https://box.kancloud.cn/dfe42a15f198115cfa6cafff57249665_1404x492.png) ![](https://box.kancloud.cn/70a35145c36ac82842578990c401b3ae_942x562.png) ### BoundSql 对应xml文件中的某一sql节点的sql语句的封装,表示动态生成的SQL语句以及相应的参数信息 当调用SqlSource的getBoundSql方法,传入的就是parameterMappings相对应的参数,最终生成BoundSql对象,有了BoundSql就可以执行sql语句了 ![](https://box.kancloud.cn/5433eba5c6edb273d7868ed890741b74_1269x380.png) 生成BoundSql ~~~ conn = sqlSession.getConfiguration().getEnvironment().getDataSource().getConnection(); ps = conn.prepareStatement(countSql); BoundSql cntBoundSql = new BoundSql(mappedStatement.getConfiguration(), countSql, boundSql.getParameterMappings(), parameter); ReflectHelper.copyFieldValue(boundSql, cntBoundSql, "additionalParameters"); ReflectHelper.copyFieldValue(boundSql, cntBoundSql, "metaParameters"); ParameterHandler parameterHandler = new DefaultParameterHandler(mappedStatement, parameter, cntBoundSql); parameterHandler.setParameters(ps); rs = ps.executeQuery(); if (rs.next()) { int var13 = rs.getInt(1); return var13; ~~~