baomidou / mybatis-plus

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

复合主键的updateById,deleteById,是否支持? #2292

Closed xinsibo closed 4 years ago

xinsibo commented 4 years ago

当前使用版本(3.3.1)

该问题是怎么引起的?**(

使用@TableId注解标记双主键,调用baseMapper 的 updateById(Entity entity)无效,会执行update table_name set 主键1=? where 主键2=?,导致唯一性约束错误。

)**

重现步骤

使用@TableId注解标记双主键,调用baseMapper 的 updateById(Entity entity)无效,会执行update table_name set 主键1=? where 主键2=?,导致唯一性约束错误。

报错信息

The error may exist in com/bqd/merchant/api/mapper/SysRoleMapper.java (best guess)

The error may involve com.bqd.merchant.api.mapper.SysRoleMapper.updateById-Inline

The error occurred while setting parameters

SQL: UPDATE CMP_SYS_ROLE SET name=?, cmp_id=? WHERE ID=?

Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (POSP.SYS_C009385)

; ORA-00001: 违反唯一约束条件 (POSP.SYS_C009385) ; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (POSP.SYS_C009385)

miemieYaho commented 4 years ago

不支持,下版本多个注解将直接启动报错