• 一个ibatis映射文件的例子(包含增删改单查,多查)


    
    
    <?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="com.ZXC.lesson.dao.LessonUserDao">

    <sql id="table">
    user
    </sql>
    <sql id="insert_parm">
    u_id,u_name,u_sex,u_age
    </sql>
    <sql id="query_parm">
    u_id,u_name,u_sex,u_age,u_create_time,u_update_time
    </sql>


    <resultMap id="id" type="com.ZXC.lesson.model.LessonUser">
    <id column="u_id" property="ID"/>
    <result column="u_name" property="Name"/>
    <result column="u_sex" property="Sex"/>
    <result column="u_age" property="Age"/>
    </resultMap>

    <insert id="save" parameterType="com.ZXC.lesson.model.LessonUser"
    useGeneratedKeys="true" keyProperty="id">
    INSERT INTO <include refid="table"/>
    (<include refid="insert_parm"/>)
    VALUES
    (#{ID},#{Name},#{Sex},#{Age})
    </insert>

    <update id="update" parameterType="com.ZXC.lesson.model.LessonUser">
    UPDATE <include refid="table"/>
    <set>
    <if test="Sex!=null">u_sex=#{Sex}</if>
    <if test="Age!=null">u_age=#{age}</if>
    </set>
    </update>

    <update id="delete" parameterType="com.ZXC.lesson.model.LessonUser">
    UPDATE <include refid="table" />
    SET is_delete=1
    WHERE u_id=#{ID}
    </update>

    <select id="querybyid" parameterType="com.ZXC.lesson.model.LessonUser">
    SELECT <include refid="query_parm"/>
    FROM <include refid="table"/>
    WHERE u_id=#{ID} AND is_delete=0
    </select>

    <select id="querylist" parameterType="com.ZXC.lesson.model.LessonUser">
    SELECT <include refid="query_parm"/>
    FROM <include refid="table"/>
    WHERE id IN
    <foreach collection="uid_list" open="(" close=")" item="uid" separator=",">
           #{ID}
       </foreach>
    AND is_delete=0
    </select>
    </mapper>
     
  • 相关阅读:
    支付宝支付
    七牛云存储介绍
    ubuntu开发机初始化
    Unity3D 正六边形,环状扩散,紧密分布,的程序
    Unity属性的封装、继承、方法隐藏
    DateTime.Now的一些用法
    [转] 增强现实 colAR Mix 浅析
    [转] Vuforia AR 中的阴影与浮现效果
    网址整理
    [转] 如何使用unity Vs来进行断点调试
  • 原文地址:https://www.cnblogs.com/television/p/9267391.html
Copyright © 2020-2023  润新知