Java EE企业级应用开发第8章 动态SQL.pptVIP

  • 27
  • 0
  • 约6.07千字
  • 约 30页
  • 2019-07-17 发布于辽宁
  • 举报
8.4 where、trim元素 where、trim元素 select * from t_customer where 1=1 choose when test=username !=null and username != and username like concat(%,#{username}, %) /when when test=jobs !=null and jobs != and jobs= #{jobs} /when otherwise and phone is not null /otherwise /choose 针对上述情况中“where 1=1”,在MyBatis的SQL中就可以使用where或trim元素进行动态处理。 where会自动判断SQL语句,只有where内的条件成立时,才会在拼接SQL中加入where关键字,否则将不会添加;还会去除多余的“AND”或“OR”。 where元素处理 trim元素处理 trim的作用是去除特殊的字符串,它的prefix属性代表语句的前缀,prefixOverrides属性代表需要去除的哪些特殊字符串,功能和where基本是等效的。 动态SQL处理 “wh

文档评论(0)

1亿VIP精品文档

相关文档