解决——》IllegalArgumentException:invalid comparison:java.util.Date and java.lang.String

版权声明:本文为博主原创文章,无需授权即可转载,甚至无需保留以上版权声明,转载时请务必注明作者。
https://blog.csdn.net/weixin_43453386/article/details/84587865

解决——》MyBatisSystemException: IllegalArgumentException:invalid comparison:java.util.Date and java.lang.String

    • 1、操作
    • 2、现象(错误信息)
    • 3、原因
      • 1)错误代码:
    • 4、解决
ntException:invalid comparison:java.util.Date and java.lang.String)

1、操作

更新对象

2、现象(错误信息)


org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
### Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
	at com.sun.proxy.$Proxy118.update(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
	at com.sun.proxy.$Proxy126.updateMapByCommunityId(Unknown Source)
	at com.eju.houseasset.service.imp.TicketServiceImpl.updateCommunity(TicketServiceImpl.java:161)
	at com.eju.houseasset.service.imp.TicketServiceImpl.auditUpdateInfo(TicketServiceImpl.java:221)
	at com.eju.houseasset.service.imp.TicketServiceImpl$$FastClassBySpringCGLIB$$56d6e0fb.invoke(<generated>)

3、原因

编写mybatis的XML文件出错,在判断空时,加入了判断空字符串的语句,无法比较 java.util.Date类型与 java.lang.Stringd的""

1)错误代码:

  • Mapper.xml
	update test
	set update_time = 
	<choose>
		<when test="value!=null and value!=''"> #{value} when> 
		<otherwise>NULLotherwise>
	choose>

4、解决

  • Mapper.xml
	update test
	set update_time = 
	<choose>
		<when test="value!=null"> #{value} when> 
		<otherwise>NULLotherwise>
	choose>
	where id=1

你可能感兴趣的:(Java,SpringMVC)