mapper.xml的基本写法

本文介绍了XML映射文件的基础写法,包括如何修改和删除代码块,以及进行查找操作。通过对XML配置的学习,可以更好地理解Java应用中的数据映射过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

修改代码块

    <update id="editContent" parameterType="com.ilearning.ssm.pojo.LessionContent">
        update tb_lession_content
        <set>
            <if test="tb_le_con_content!=null">
                tb_le_con_content=#{tb_le_con_content},
            </if>
            <if test="tb_le_con_video!=null">
                tb_le_con_video=#{tb_le_con_video}
            </if>
        </set>
        where tb_le_con_content=#{tb_le_con_content}
    </update>

删除代码块

   <delete id="delContent" parameterType="com.ilearning.ssm.pojo.LessionContent">
        delete from tb_lession_content
        <where>
            <if test="tb_le_id!=0">
                and tb_le_id = #{tb_le_id}
            </if>
            <if test="tb_le_con_id!=0">
                and  tb_le_con_id = #{tb_le_con_id}
            </if>
            <if test="tb_le_con_content!=null and tb_le_con_content!=''"  >
                and tb_le_con_content = #{tb_le_con_content}
            </if>
        </where>
    </delete>

查找

      <select id="findTeacher" resultType="com.ilearning.ssm.pojo.Teacher" parameterType="com.ilearning.ssm.pojo.Teacher">
        select
            t1.tb_tid,t1.tb_tname,t1.tb_tgrade,t1.tb_tcourse,t1.tb_tdetail,t1.tb_tpic,t1.tb_tdata,t2.tb_tud
        from
            tb_teacher AS t1
        INNER JOIN
            tb_teacher_manager AS t2 on t1.tb_tid=t2.tb_tid
        <where>
            <if test="tb_tid!=null">
                and t1.tb_tid = #{tb_tid}
            </if>
            <if test="tb_tid!=null">
                and t1.tb_tid = #{tb_tid}
            </if>
        </where>
    </select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力的小豆子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值