嚴重: Servlet.service() for servlet [spring] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: java
### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
表面上看是由於類型不符合, 可是想了想, Date類型對應MySQL的datetime, 以及mapper中jdbcType都沒問題啊. 並且徹底同樣的東西在原工程中是徹底正常的. 既然都是同樣的代碼, 那就找找倆工程有啥不同的吧mysql
首先是MySQL jar版本不一樣. 換成原工程中的版本也無效. 而後是mybatis jar版本不同, 換成原工程中的版本問題就解決了!spring
原工程中配置的是mybatis-3.2.8, 而我測試工程中用的是mybatis-3.3.1.後來在網上找了一下才知道了緣由:sql
原來這是mybatis 3.3.0中對於時間參數進行比較時的一個bug. 若是拿傳入的時間類型參數與空字符串''進行對比判斷則會引起異常. 因此在上面的代碼中去該該判斷, 只保留非空判斷就正常了apache
例如:在xxMapper.xml的把mybatis
<update id="updAccount" parameterType="com.isoftstone.ci.user.domain.Account" >
update usr_account set
<trim suffixOverrides="," >
<if test="sysAccountType != null ">
sys_account_type=#{sysAccountType},
</if>
<if test="realNameAuthed != null ">
real_name_authed=#{realNameAuthed},
</if>
<if test="lastLoginAt != null and lastLoginAt != ' ' ">
last_login_at=#{lastLoginAt}
</if>
</trim>
where id=#{id}
</update>app
將代碼換下面的代碼(去掉時間跟空字符串的比較 lastLoginAt != ' ')dom
<update id="updAccount" parameterType="com.isoftstone.ci.user.domain.Account" >
update usr_account set
<trim suffixOverrides="," >
<if test="sysAccountType != null ">
sys_account_type=#{sysAccountType},
</if>
<if test="realNameAuthed != null ">
real_name_authed=#{realNameAuthed},
</if>
<if test="lastLoginAt != null ">
last_login_at=#{lastLoginAt}
</if>
</trim>
where id=#{id}
</update>ide