MyBatis mapper.xml文件中的curd语句

来源:互联网 发布:淘宝看不到卖家中心 编辑:程序博客网 时间:2024/06/05 11:43
  1.   <resultMap id="BaseResultMap" type="com.mzj.model.BizFriendLink">
        <id column="ID" jdbcType="CHAR" property="id" />
        <result column="NAME" jdbcType="VARCHAR" property="name" />
        <result column="MEMO" jdbcType="VARCHAR" property="memo" />
        <result column="URL" jdbcType="VARCHAR" property="url" />
        <result column="SORT" jdbcType="DECIMAL" property="sort" />
        <result column="STATE" jdbcType="CHAR" property="state" />
        <result column="PID" jdbcType="CHAR" property="pid" />
        <result column="STYLE" jdbcType="VARCHAR" property="style" />
      </resultMap>
     <insert id="saveFriendLink" parameterType="com.mzj.model.BizFriendLink" useGeneratedKeys="true" keyProperty="id">
     insert into BIZ_FRIEND_LINK (id,name,url,style,sort,state,memo,pid)
      values (#{id},#{name,jdbcType=VARCHAR},#{url,jdbcType=VARCHAR},#{style,jdbcType=VARCHAR},
    #{sort,jdbcType=DECIMAL},#{state,jdbcType=VARCHAR},#{memo,jdbcType=VARCHAR},#{pid,jdbcType=VARCHAR})
     </insert>
     
     <update id="updateFriendLink" parameterType="com.mzj.model.BizFriendLink">
     update BIZ_FRIEND_LINK
     <set>
      <if test="name != null">
      name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
      url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="style != null">
      style = #{style,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
      sort = #{sort,jdbcType=DECIMAL},
      </if>
      <if test="state != null">
      state = #{state,jdbcType=VARCHAR},
      </if>
      <if test="pid != null">
      pid = #{pid,jdbcType=VARCHAR},
      </if>
      <if test="memo != null">
      memo = #{memo,jdbcType=VARCHAR},
      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
          </update>
     
    </mapper>
0 0
原创粉丝点击