首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

使用Mybatis Generator自动生成Mybatis相关代码,批改生成xml格式

2014-01-01 
使用Mybatis Generator自动生成Mybatis相关代码,修改生成xml格式现在程序生成的xml代码段:update idupd

使用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>
[解决办法]
我生成的实体类怎么多了很多属性啊

热点排行