script

要在带注解的映射器接口类中使用动态 SQL,可以使用 script 元素。比如:

  1. @Update({"<script>",
  2. "update Author",
  3. " <set>",
  4. " <if test='username != null'>username=#{username},</if>",
  5. " <if test='password != null'>password=#{password},</if>",
  6. " <if test='email != null'>email=#{email},</if>",
  7. " <if test='bio != null'>bio=#{bio}</if>",
  8. " </set>",
  9. "where id=#{id}",
  10. "</script>"})
  11. void updateAuthorValues(Author author);