我在MyBatis v3 mapper xml中动态生成where子句.但放置括号真的很麻烦.是否有一种更简单的方法来处理问题而不使用if语句?
file.lref = #{filter.lref}
(
subject LIKE #{filter.forLike}
OR requester_identifier LIKE #{filter.forLike}
OR requester_name LIKE #{filter.forLike}
OR file_id = #{filter.forInt}
)
AND file_status_link.dosya_ref is not NULL
AND file_status_link.dosya_ref is NULL
示例动态生成的SQL输出如下
WHERE ( subject LIKE ? OR requester_identifier LIKE ? OR requester_name LIKE ? )
AND file_status_link.dosya_ref is NULL