Mybatis SQL语句常见异常
"resultMsg":"nested exception is org.apache.ibatis.exceptions.PersistenceException:
\r\n### Error querying database.
Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String\r\n###
Cause: java.lang.IllegalArgumentException:
invalid comparison: java.util.Date and java.lang.String"
mybatis中加上日期类型( dbcType=DATE )即可:
festival_end_date >=#{festivalEndDate, jdbcType=DATE}
另外,特殊字符 替代符号(红色基本为常用的)
& &
< <
> >
" "
' '
小于等于 a<=b a <= b a <![CDATA[<= ]]>b
大于等于 a>=b a >= b a <![CDATA[>= ]]>b
不等于 a!=ba <![CDATA[ <> ]]>b a <![CDATA[!= ]]>b
例子:
<if test="provinceId != null">
AND <![CDATA[ province_id = #{provinceId} ]]>
</if>
<if test="id != null">
AND <![CDATA[ id <> #{id} ]]>
</if>
网友评论