配置文件一mapper.xml

Posted loveer

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了配置文件一mapper.xml相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="dao.AreaDao">

    <select id="queryArea" resultType="entity.Area">
        SELECT area_id,
               area_name,
               area_desc,
               priority,
               create_time,
               last_edit_time
        FROM tb_area
        ORDER BY priority DESC
    </select>

    <insert id="insertArea" useGeneratedKeys="true" keyProperty="areaId" keyColumn="area_id">
        INSERT INTO tb_area(area_name, area_desc, priority,
                            create_time, last_edit_time)
        VALUES (#areaName, #areaDesc, #priority,
                #createTime, #lastEditTime)
    </insert>

    <update id="updateArea" parameterType="entity.Area">
        update tb_area
        <set>
            <if test="areaName != null">area_name=#areaName,</if>
            <if test="areaDesc != null">area_desc=#areaDesc,</if>
            <if test="priority != null">priority=#priority,</if>
            <if test="lastEditTime != null">last_edit_time=#lastEditTime</if>
        </set>
        where area_id=#areaId
    </update>

    <delete id="deleteArea">
        DELETE
        FROM tb_area
        WHERE area_id =
              #areaId
    </delete>

    <delete id="batchDeleteArea" parameterType="long">
        DELETE FROM
        tb_area
        WHERE area_id IN
        <foreach collection="list" item="areaId" open="(" separator=","
                 close=")">
            #areaId
        </foreach>
    </delete>

</mapper>

以上是关于配置文件一mapper.xml的主要内容,如果未能解决你的问题,请参考以下文章

mapper.xml配置文件,方便复制

mybatis配置文件形式

**Mapper.xml配置文件(不同情况不同配置)

MyBatis学习存档——mapper.xml映射文件

Spring Boot简单xml配置集成mybatis

spring 整合mybatis后 若mapper.java与mapper.xml不在同一文件夹,该怎么配置