基于javaEE的简单教务系统实现(八)

<?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.system.mapper.SelectedcourseMapper" >
  <resultMap id="BaseResultMap" type="com.system.po.Selectedcourse" >
    <result column="courseID" property="courseid" jdbcType="INTEGER" />
    <result column="studentID" property="studentid" jdbcType="INTEGER" />
    <result column="mark" property="mark" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    courseID, studentID, mark
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.system.po.SelectedcourseExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from selectedcourse
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <delete id="deleteByExample" parameterType="com.system.po.SelectedcourseExample" >
    delete from selectedcourse
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.system.po.Selectedcourse" >
    insert into selectedcourse (courseID, studentID, mark
      )
    values (#{courseid,jdbcType=INTEGER}, #{studentid,jdbcType=INTEGER}, #{mark,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.system.po.Selectedcourse" >
    insert into selectedcourse
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="courseid != null" >
        courseID,
      </if>
      <if test="studentid != null" >
        studentID,
      </if>
      <if test="mark != null" >
        mark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="courseid != null" >
        #{courseid,jdbcType=INTEGER},
      </if>
      <if test="studentid != null" >
        #{studentid,jdbcType=INTEGER},
      </if>
      <if test="mark != null" >
        #{mark,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.system.po.SelectedcourseExample" resultType="java.lang.Integer" >
    select count(*) from selectedcourse
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update selectedcourse
    <set >
      <if test="record.courseid != null" >
        courseID = #{record.courseid,jdbcType=INTEGER},
      </if>
      <if test="record.studentid != null" >
        studentID = #{record.studentid,jdbcType=INTEGER},
      </if>
      <if test="record.mark != null" >
        mark = #{record.mark,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update selectedcourse
    set courseID = #{record.courseid,jdbcType=INTEGER},
      studentID = #{record.studentid,jdbcType=INTEGER},
      mark = #{record.mark,jdbcType=INTEGER}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>

 

posted @ 2021-05-13 16:58  凋零_(  阅读(67)  评论(0)    收藏  举报