Closed wnwnfgx closed 1 year ago
跟你jpa插入没有id没什么关系,请确定你有没有主键
确定是有的
如果Entity中的id列定义成这样就没有问题,但太多地方要修改了,是否seata不支持postgresql的serial自增主键呢?使用的seata版本是1.6.1
@id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ms_people_seq") @SequenceGenerator(sequenceName = "ms_people_seq", name = "ms_people_seq", allocationSize = 1) private Long id;
当时支持多主键上有个bug,导致不读自增主键,你尝试升级1.7看看
在Entity中的自增主键定义为
@Id @GeneratedValue(strategy= GenerationType.IDENTITY) private Long id;
Jpa会自动创建表的序列和主键Id列(类型为 serial8 )。SpringDataJpa在insert数据时不会写入id列的值,导致Seata AT模式在insert数据时报错 :io.seata.common.exception.ShouldNeverHappenException: pkIndex is not found