mybatis trim

eg:

     select * from user 

  <trim prefix="WHERE" prefixoverride="AND |OR">

    <if test="name != null "> AND name=#{name}</if>

    <if test="gender != null "> AND gender=#{gender}</if>

  </trim>

  如果name和gender的值都不为null的话打印的SQL为:select * from user where    name = '****' and gender = '***'

  prefix:前缀      

  prefixoverride:去掉第一个and或者是or

posted on 2016-11-22 15:35  xiaohehe2  阅读(190)  评论(0编辑  收藏  举报

导航