apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.35k stars 8.79k forks source link

Gts does a date type operation in DML and reports org.apache.ibatis.type.TypeException #1253

Open 1iqueen opened 5 years ago

1iqueen commented 5 years ago

Ⅰ. Issue Description

在使用springboot操作数据库时,mysql指定了创建时间类型为datatime格式,但是做dml操作时,会出现类型类型映射问题,

Ⅱ. Describe what happened

If there is an exception, please attach the exception trace:

==>  Preparing: update system_message set status_code_key = ?, function_module_id = ?, message_title= ?, include_variable_flag = ?, gmt_create = ? where 1=1 and system_message_id = ? and is_deleted = 0 
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2bf2fb75]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2bf2fb75]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2bf2fb75]
2019-06-28 18:28:51 - com.meizhilab.basis.system.common.GenericExceptionHandler -34218 [http-nio-8082-exec-1] ERROR com.meizhilab.basis.system.common.GenericExceptionHandler  - 未知异常
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='gmtCreate', mode=IN, javaType=class java.time.LocalDateTime, jdbcType=DATE, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #5 with JdbcType DATE . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Error

Ⅲ. Describe what you expected to happen

对时间格式的数据,能正常dml,ddl

Ⅳ. How to reproduce it (as minimally and precisely as possible)

对没有jdbcType映射的sql去操作dml,可能会发生这个问题

Ⅴ. Anything else we need to know?

在kt.mybatis做操作的时候,使用gts-client需要做哪些必要的操作?

Ⅵ. Environment:

fescar-robot commented 5 years ago

Hi @1iqueen, we detect non-English characters in the issue. This comment is an auto translation from @fescar-robot to help other users to understand this issue. We encourage you to describe your issue in English which is more friendly to other users.

Gts does a date type operation in DML and reports org.apache.ibatis.type.TypeException

Ⅰ. Issue Description

When using springboot to manipulate the database, mysql specifies the creation time type as datatime format, but when doing dml operation, type type mapping problem will occur.

Ⅱ. Describe what happened

If there is an exception, please attach the exception trace:

==>  Preparing: update system_message set status_code_key = ?, function_module_id = ?, message_title= ?, include_variable_flag = ?, gmt_create = ? where 1=1 and system_message_id = ? and is_deleted = 0 
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2bf2fb75]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2bf2fb75]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2bf2fb75]
2019-06-28 18:28:51 - com.meizhilab.basis.system.common.GenericExceptionHandler -34218 [http-nio-8082-exec-1] ERROR com.meizhilab.basis.system.common.GenericExceptionHandler  - 未知异常
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='gmtCreate', mode=IN, javaType=class java.time.LocalDateTime, jdbcType=DATE, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #5 with JdbcType DATE . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Error

Ⅲ. Describe what you expected to happen

For time format data, normal dml, ddl

Ⅳ. How to reproduce it (as minimally and precisely as possible)

This problem may occur when you run dml on sql without jdbcType mapping.

Ⅴ. Anything else we need to know?

What do you need to do to use gts-client when doing kt.mybatis?

Ⅵ. Environment:

slievrly commented 5 years ago

@1iqueen which type of transaction.undo.log.serialization in your file.conf