错误信息如下:
Cause: org.postgresql.util.PSQLException: 错误: 无法确定参数 $1 的数据类型
xml示例如下:
……
<if test="name != null and name != ''">and t1."name" like concat('%', #{name}, '%')</if>
<if test="status != null and status != ''">and t1.status = #{status}</if>
……
经排查发现是第一个if条件中的like参数出现无法识别数据类型的异常,将其强转一下类型即可
<if test="name != null and name != ''">and t1."name" like concat('%', #{name}::text, '%')</if>
数值类型用INTERVAL,或者用${}接收参数,但是这样无法预防SQL注入,不建议采用