baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.42k stars 4.31k forks source link

在插入createTime(在Java中是LocalDateTime类型,在mysql中是datetime类型)这个字段时,报错 #6164

Closed JankinWong closed 5 months ago

JankinWong commented 6 months ago

当前使用版本 mybatis-plus 3.0.1;mybatis 3.4.6; mysql-connector-java 5.1.38; HikariCP 2.7.0 当前环境信息 Java8+Mysql5.7.28 描述bug现象 在插入createTime(在Java中是LocalDateTime类型,在mysql中是datetime类型)这个字段时,报错:Cause: java.lang.IllegalArgumentException: argument type mismatch 提供问题复现步骤 java实体中设置实体类的createTime字段 user.setCreateTime(LocalDateTime.now()); 提供完整堆栈日志(可选) Caused by: org.apache.ibatis.exceptions.PersistenceException:

Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'createTime' of 'class com.example.entity.User' with value 'Tue May 14 14:35:18 CST 2024' Cause: java.lang.IllegalArgumentException: argument type mismatch

Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'createTime' of 'class com.example.entity.User' with value 'Tue May 14 14:35:18 CST 2024' Cause: java.lang.IllegalArgumentException: argument type mismatch

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.saveBatch(ServiceImpl.java:125)

提供问题复现工程(可选) 请尽量提供复现工程,减少大家排错的时间.

refeccd commented 6 months ago

你这版本也太低了 升到最新版试试,盲猜是驱动的问题

JankinWong commented 5 months ago

你这版本也太低了 升到最新版试试,盲猜是驱动的问题 只升级mp版本吗?

miemieYaho commented 5 months ago

type映射与mp无关

VampireAchao commented 5 months ago

莫吵架,伤和气