mybatis 异常 invalid comparison: java.util.Date and java.lang.String

mybatis 3.4.6,日期字段做比较操作,日期字段为空时,报错

2018-04-06 18:04:26,614  INFO [OrderRelationController.java:345] : nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying 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
2018-04-06 18:04:26,815 ERROR [MIBaseController.java:69] : 调用search接口。返回结果:{"body":{},"head":{"appVersion":"","dataVersion":"","deployVersion":"","msgCount":"","rspCode":"1","rspMsg":"查询失败"}}
经查是mybatis的bug,在对日期字段进行比较操作时,只能做null判断,不能做空串判断
  
    	 and ordertime >= #{startTime} 
    	 and ordertime <=#{endTime} 
  

正确的配置如下:

  
    	 and ordertime >= #{startTime} 
    	 and ordertime <=#{endTime} 
  


你可能感兴趣的:(mybatis)