插入mysql数据库异常

发布时间:2023年12月21日

错误号:1785::符号:ER_GTID_UNSAFE_NON_TRANSACTIONAL_TABLE; SQLSTATE:HY000
消息:语句违反了GTID的一致性:非事务表的更新只能在自动提交的语句或单语句事务中完成,而不能在与事务表的更新相同的语句中完成。

### Cause: java.sql.SQLException: Statement violates GTID consistency: Updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.
2023-12-21T01:42:52.128996707Z ; uncategorized SQLException; SQL state [HY000]; error code [1785]; Statement violates GTID consistency: Updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.; nested exception is java.sql.SQLException: Statement violates GTID consistency: Updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.
2023-12-21T01:42:52.129001805Z 	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89)
CREATE TABLE `seeding_news_record` (
  `id` bigint(32) NOT NULL AUTO_INCREMENT,
  `news_type` varchar(100) DEFAULT NULL COMMENT '消息类型',
  `content` varchar(5000) DEFAULT NULL COMMENT '消息内容',
  `sender` varchar(100) DEFAULT NULL COMMENT '发送人',
  `send_time` datetime DEFAULT NULL COMMENT '发送时间',
  `receive` varchar(5000) DEFAULT NULL COMMENT '接收人',
  `jobNum` varchar(5000) DEFAULT NULL COMMENT '一卡通号',
  `read` int(1) DEFAULT NULL COMMENT '已读标识',
  `send_status` int(1) DEFAULT NULL COMMENT '发送状态',
  `status` int(1) DEFAULT NULL COMMENT '状态',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  `create_by` varchar(100) DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(100) DEFAULT NULL COMMENT '操作员',
  `update_time` datetime DEFAULT NULL COMMENT '操作时间',
  `version` int(10) DEFAULT NULL COMMENT '版本',
  `field1` varchar(100) DEFAULT NULL,
  `field2` varchar(100) DEFAULT NULL,
  `field3` text,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=55 DEFAULT CHARSET=utf8 COMMENT='消息发送信息表';

原因:与同事务表中的存储引擎类型不一致 新增表是?ENGINE=MyISAM 原表是ENGINE=InnoDB 造成无法再同一事务下

@Transactional(rollbackFor = Exception.class)

进行新增

CREATE TABLE `seeding_audit` (
  `id` bigint(32) NOT NULL AUTO_INCREMENT,
  `business_id` bigint(20) DEFAULT NULL COMMENT '审批业务ID',
  `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci DEFAULT NULL COMMENT '审批标题',
  `audit_type` tinyint(4) DEFAULT NULL COMMENT '审批类型;',
  `audit_status` tinyint(4) DEFAULT NULL COMMENT '审批状态:1,待审核;2,审核通过;3,审核被驳回',
  `audit_remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci COMMENT '备注',
  `dr` smallint(6) DEFAULT '0' COMMENT '逻辑删除标志,0表示未删除,1表示删除',
  `def1` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci DEFAULT NULL,
  `def2` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci DEFAULT NULL,
  `def3` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci DEFAULT NULL,
  `def4` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci DEFAULT NULL,
  `def5` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci DEFAULT NULL,
  `card_solution` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_roman_ci DEFAULT NULL COMMENT '',
  `create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_user` bigint(20) DEFAULT NULL COMMENT '修改人',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COMMENT='审核记录表';
文章来源:https://blog.csdn.net/ZLNEWCSDN/article/details/135124314
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。