[seata]执行sql出现错误Fail to get auto-generated keys, use 'SELECT LAST_INSERT_ID()' instead. Be cautious, statement could be polluted. Recommend you set the statement to return generated keys.

2024-07-15 685 views
4
现象

在执行sql时,会出现错误:Fail to get auto-generated keys, use 'SELECT LAST_INSERT_ID()' instead. Be cautious, statement could be polluted. Recommend you set the statement to return generated keys.

环境

seata 1.4.2 jdk 1.8 springboot 2.3.12.RELEASE 主键为自增

回答

8

数据库版本 driver版本

2

数据库版本 mysql 5.7.37-log mysql-connector版本 6.0.6 数据源类型 com.alibaba.druid.pool.DruidDataSource 依赖版本 druid-spring-boot-starter 1.1.10

1

undolog的id字段有没有去掉?

7

在建表的时候就没有id字段 CREATE TABLE undo_log ( branch_id bigint(20) NOT NULL COMMENT 'branch transaction id', xid varchar(128) NOT NULL COMMENT 'global transaction id', context varchar(128) NOT NULL COMMENT 'undo_log context,such as serialization', rollback_info longblob NOT NULL COMMENT 'rollback info', log_status int(11) NOT NULL COMMENT '0:normal status,1:defense status', log_created datetime(6) NOT NULL COMMENT 'create datetime', log_modified datetime(6) NOT NULL COMMENT 'modify datetime', UNIQUE KEY ux_undo_log (xid,branch_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='AT transaction mode undo table'

8

driver换成5.1.47试试

6
  1. 这个准确来说是警告,看一下你的mybatis版本,如果比较低的话就升级一下或者手动指定一下返回主键