<insert id="insertSelective" parameterType="cn.springmvc.model.Info" >
insert into info
<trim prefix="(" suffix=")" suffixOverrides="," >
<!--prefix="(" suffix=")"在前后加上()suffixOverrides=","去掉最后多余的"," -->
<!-- 判断id字段是否为空 -->
<if test="id != null" >
id,
</if>
<if test="imagerurl != null" >
imagerurl,
</if>
<if test="allclick != null" >
allclick,
</if>
<if test="clicktype != null" >
clicktype,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="imagerurl != null" >
#{imagerurl,jdbcType=VARCHAR},
</if>
<if test="allclick != null" >
#{allclick,jdbcType=BIT},
</if>
<if test="clicktype != null" >
#{clicktype,jdbcType=INTEGER},
</if>
</trim>
</insert>
相当于:insert into info (id ,imagerurl,allclick,clicktype )values (#{id,jdbcType=INTEGER},#{imagerurl,jdbcType=VARCHAR},#{allclick,jdbcType=BIT},#{clicktype,jdbcType=INTEGER})
mybaits Mapping中的知识
最新推荐文章于 2024-02-28 16:30:19 发布