mybatis笔记-MappedStatement

1.概念

MappedStatement维护了一条<select|update|delete|insert>节点的封装

1.1 Mapper.xml

比如Mapper.xml中一个<select />节点

    <select id="selectAuthorLinkedHashMap" resultType="java.util.LinkedHashMap">
        select id, username from author where id = #{value}
    </select>

1.2 获取MappedStatement类

转换成Java类就是一个MappedStatement

使用Configuration的getMappedStatement方法来获取MappedStatement对象

获取的方式key的组成为命名空间+id

sqlMapper.getConfiguration().getMappedStatement(
"org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectAuthorLinkedHashMap")

2. SqlSource

负责根据用户传递的parameterObject,动态地生成SQL语句,将信息封装到BoundSql对象中,并返回

3. BoundSql

表示动态生成的SQL语句以及相应的参数信息

当调用SqlSource的getBoundSql方法,传入的就是parameterMappings相对应的参数,最终生成BoundSql对象,有了BoundSql就可以执行sql语句了

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容