本帖最后由 zhaohao19853 于 2012-12-21 16:58:23 编辑

解决方案 »

  1.   

    ibatis 是可以插入null值的,只要数据库设置允许Null即可插入成功!
      

  2.   

    to 1楼,ibatis能插入null值么?不是"null"噢???
      

  3.   

    <insert id="insert" parameterType="map"> 
             INSERT INTO TABLENAME (
            <trim suffixOverrides=",">
               <if test="userId != null and userId != ''">#{userId},</if>
               <if test="userName!= null and userName!= ''">#{userName},</if>
            </trim>
            )
            VALUES (
            <trim suffixOverrides=",">
                <if test="userId != null and userId != ''">userId,</if>
                <if test="userName!= null and userName!= ''">userName,</if>
            </trim>
            )
       </insert>