錯(cuò)誤信息如下:
Cause: org.postgresql.util.PSQLException: 錯(cuò)誤: 無法確定參數(shù) $1 的數(shù)據(jù)類型
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>
……
經(jīng)排查發(fā)現(xiàn)是第一個(gè)if條件中的like參數(shù)出現(xiàn)無法識(shí)別數(shù)據(jù)類型的異常羊始,將其強(qiáng)轉(zhuǎn)一下類型即可
<if test="name != null and name != ''">and t1."name" like concat('%', #{name}::text, '%')</if>
數(shù)值類型用INTERVAL帮匾,或者用${}接收參數(shù),但是這樣無法預(yù)防SQL注入宵蛀,不建議采用