isNotNull与isNotEmpty的区别

<isNotNull>

检查属性是否不为null

<isNotEmpty>

检查Collection.size()的值,属性的String或String.valueOf()值,是否不为null或不为空(“”或size() > 0)

 
----------------------使用----------------------
  1. <!-- 分页查询返回列表 -->
  2. <select id="getUserPrivacyPage" parameterClass="map" resultClass="hashmap">
  3. select uid,`key`,`value` from ts_user_privacy
  4. <dynamic prepend="WHERE">
  5. <isNotEmpty prepend="AND" property="uid">
  6. uid=#uid#
  7. </isNotEmpty>
  8. <isNotEmpty prepend="AND" property="key">
  9. key=#key#
  10. </isNotEmpty>
  11. <isNotEmpty prepend="AND" property="value">
  12. value=#value#
  13. </isNotEmpty>
  14. </dynamic>
  15. <isNotEmpty prepend="order by " property="_order">
  16. $_order$
  17. </isNotEmpty>
  18. <isNotEmpty prepend="limit " property="_limit">
  19. #_limit._pstart#,#_limit._psize#
  20. </isNotEmpty>
  21. </select>

<!-- 修改记录 -->

  1. <update id="updateUserPrivacy"  parameterClass="map">
  2. update ts_user_privacy
  3. <dynamic  prepend="set">
  4. <isNotNull prepend=","  property="value"> `value`=#value# </isNotNull>
  5. </dynamic>
  6. where uid=#uid# AND `key`=#key#
  7. </update>

http://huangqiqing123.iteye.com/blog/1668963

上一篇:【MySQL 高级】架构介绍


下一篇:面向游戏玩家的六款最佳Linux发行版