日期:2014-05-17  浏览次数:20647 次

使用Mybatis Generator自动生成Mybatis相关代码,修改生成xml格式
现在程序生成的xml代码段:
  <update id="updateByPrimaryKeySelective" parameterType="test.domain.USERS">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Oct 16 15:13:05 CST 2011.
    -->
    update USERS
    <set>
      <if test="name != null">
        NAME = #{name,jdbcType=VARCHAR},
      </if>
      <if test="hiredate != null">
        HIREDATE = #{hiredate,jdbcType=DATE},
      </if>
      <if test="operator != null">
        OPERATOR = #{operator,jdbcType=VARCHAR},
      </if>
      <if test="operatedate != null">
        OPERATEDATE = #{operatedate,jdbcType=DATE},
      </if>
    </set>
    where PID = #{pid,jdbcType=VARCHAR}
  </update>

希望生成的代码格式
<update id="update" parameterType="com.neusoft.ph.example.orm.user.User">
update USERS
    <set>
     <if test="modifiableData.containsKey('name')">NAME = #{name,jdbcType=VARCHAR},</if>
     <if test="modifiableData.containsKey('hiredate')">HIREDATE = #{hiredate,jdbcType=DATE}</if>
    </set>
    where PID = #{pid,jdbcType=VARCHAR}
</update>


刚看了mybatis-generator-core-1.3.1的doc  都是英文的看不懂,求大虾指点怎么实现改变生成代码的格式

------解决方案--------------------
参考FortuneJ中的CodeSmith模板生成MyBaits代码
不过MyBaits是3.0的语法

参考地址www.cnblogs.com/mail-ricklee
------解决方案--------------------
在配置文件根目录下加上这句 

<!-- 去除自动生成的注释 -->
 <commentGenerator>
  <property name="suppressAllComments" value="true" />
 </commentGenerator>
------解决方案--------------------