[MyBatis Error] invalid comparison java.util.Date and java.lang.String
Background
Compare date in where clauses of MyBatis mapper XML query.
<if test="beginTime != null and beginTime != ''"> |
Error Info
nested exception is org.apache.ibatis.exceptions.PersistenceException: |
Solutions
remove beginTime != ''
in the <if>
element of MyBatis mapper XML file.
<if test="beginTime != null"> |
Reasons
When you pass Date
objects as a parameter to MyBatis mapper XML query, you can’t compare the Date
object with a String
object in MyBatis <if>
elements.