1.课程介绍
1. Mybatis原理回顾;(了解)
2. Mybatis使用回顾;(了解)
4. Mybatis映射器(掌握)
5. Mybatis结果映射(掌握)
6. Mybatis懒加载操作(了解)
6. Mybatis二级缓存(了解)
7. SSM集成(掌握)
Mybatis映射器(掌握)
<mapper namespace="cn.itsource._01mapper.mapper.EmployeeMapper">
<sql id="whereSql">
<!-- where会自动替换第一个and
count可以拼接
代码块 <![CDATA[ 中间写需要转译的符号]]>-->
<where>
<if test="name!=null and name!=''">
and name like count("%"#{name}"%")
</if>
<if test="minAge!=null">
and age >=#{minAge}
</if>
<if test="maxAge!=null">
<![CDATA[
and age <= #{maxAge}
]]>
</if>
</where>
</sql>
<!--查询一共多少条数据-->
<select id="getCount" resultType="long" parameterType="cn.itsource._01mapper.query.EmployeeQuery">
select (*) from employee
<include refid="whereSql"/>
</select>
<!--条件查询-->
<select id="queryAll" parameterType="cn.itsource._01mapper.query.EmployeeQuery"
resultType="cn.itsource._01mapper.domain.Employee">
select * from employee
<include refid="whereSql"/>
</select>
<!--查询一条-->
<select id="findOne" parameterType="long" resultType="cn.itsource._01mapper.domain.Employee">
select * from employee where id =#{id}
</select>
<!--查询所有-->
<select id="findAll" resultType="cn.itsource._01mapper.domain.Employee">
select * from employee
</select>
Mybatis结果映射(掌握)
多对一
<!--namespace的命名空间和接口的全限定名一致-->
<mapper namespace="cn.itsource._02_many2one_result.ProductMapper">
<resultMap id="productMap" type="cn.itsource._