当前使用版本(必填,否则不予处理)

3.5.1

该问题是如何引起的?(确定最新版也有问题再提!!!)

类含有LocalDate字段,表对应类型为date,批量插入时,类型转换异常 (换成 LocalDateTime 和datetime也一样; 单条插入时没有问题)

重现步骤(如果有就写完整)

类包含的字段: @TableField("test_date") private LocalDate testDate; 实现 MyBatis-Plus saveBatch的对象带有LocalDate时产生的问题

报错信息

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error flushing statements. Cause: java.lang.ClassCastException: class java.time.LocalDate cannot be cast to class java.sql.Date (java.time.LocalDate is in module java.base of loader 'bootstrap'; java.sql.Date is in module java.sql of loader 'platform')

Cause: java.lang.ClassCastException: class java.time.LocalDate cannot be cast to class java.sql.Date (java.time.LocalDate is in module java.base of loader 'bootstrap'; java.sql.Date is in module java.sql of loader 'platform')

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.executeBatch(SqlHelper.java:192)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.executeBatch(SqlHelper.java:217)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.executeBatch(ServiceImpl.java:240)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.saveBatch(ServiceImpl.java:136)
at com.baomidou.mybatisplus.extension.service.IService.saveBatch(IService.java:73)
at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>)

MyBatis-Plus saveBatch的对象带有LocalDate时产生的问题

Comment From: qmdx

类型不匹配,自行解决