Skip to content

mybatis 使用 InsertSelectiveMapper插入带有自增键的数据 SELECT LAST_INSERT_ID()执行报错 #3426

Open
@porter-fancy

Description

@porter-fancy

version 3.5.6
数据库类型 MYSQL8.0

@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "accrual_grant_condition")
public class AccGrantCondition {
    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "group_id")
    private String groupId;
}

@mapper
public interface AccGrantConditionMapper extends AppMapper<AccGrantCondition> {
}
执行这个方法 提示报错
 accrualGrantConditionMapper.insertSelective(condition);

错误信息
### Error updating database.  Cause: org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: java.sql.SQLException: Error
### The error may exist in com/gaiaworks/acc/rules/dao/mapper/AccGrantConditionMapper.java (best guess)
### The error may involve com.gaiaworks.acc.rules.dao.mapper.AccGrantConditionMapper.insertSelective!selectKey
### The error occurred while executing a query
### SQL: SELECT LAST_INSERT_ID()
### Cause: org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: java.sql.SQLException: Error

之前怀疑是数据库的问题 但是同步对比正常环境的数据库 和 异常的数据库参数配置一致,并且从异常的数据库里的审计日志并未找到SELECT LAST_INSERT_ID()的相关报错日志。想请教下 后续该往什么方向继续排查这个错误

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions