当前位置:   article > 正文

动态 SQL ——之—— suffixOverrides & prefix & suffix

suffixoverrides

suffixOverrides 它的作用是移除所有指定在 suffixOverrides属性中的内容。 suffix Overrides ——>后缀 覆盖


  1. <!-- keyProperty="id">
  2. <insert id="insert" useGeneratedKeys="true">
  3. insert into Count
  4. <trim prefix="(" suffix=")" suffixOverrides=",">
  5. <if test="countType != null">
  6. CountType,
  7. </if>
  8. <if test="countKey != null">
  9. CountKey,
  10. </if>
  11. <if test="countValue != null">
  12. CountValue,
  13. </if>
  14. <if test="lastUpdateTime != null">
  15. LastUpdateTime,
  16. </if>
  17. <if test="remark != null">
  18. Remark,
  19. </if>
  20. </trim>
  21. <trim prefix="values (" suffix=")" suffixOverrides=",">
  22. <if test="countType != null">
  23. #{countType,jdbcType=VARCHAR},
  24. </if>
  25. <if test="countKey != null">
  26. #{countKey,jdbcType=VARCHAR},
  27. </if>
  28. <if test="countValue != null">
  29. #{countValue,jdbcType=INTEGER},
  30. </if>
  31. <if test="lastUpdateTime != null">
  32. getDate(),
  33. </if>
  34. <if test="remark != null">
  35. #{remark,jdbcType=VARCHAR},
  36. </if>
  37. </trim>
  38. </insert>

参数
String countType = "BBQ";String countKey = "BBQ";Date lastUpdateTime = new Date();
执行SQL
insert into Count ( CountType, CountKey, LastUpdateTime ) values ( ?, ?, getDate() )

参数
String countType = "BBQ";String countKey = "BBQ";
执行SQL
insert into Count ( CountType, CountKey ) values ( ?, ? )

根据入参和 SQL 慢慢体会使用 


参考文章

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/855382
推荐阅读
相关标签
  

闽ICP备14008679号