8-20mabits映射器and_ssm集成

本文深入探讨了Mybatis映射器和结果映射的使用,包括多对一、一对多关系的配置,并重点讲解了SSM(Spring、Spring MVC、Mybatis)的集成过程,涉及先导包、配置文件如applicationcontext.xml和web.xml的设置。
摘要由CSDN通过智能技术生成

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._
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值