mybatis-mapper / mapper

MyBatis Mapper
https://mapper.mybatis.io
Apache License 2.0
325 stars 47 forks source link

如何实现根据自定义策略自动生成主键 #28

Closed kk-cheng-1024 closed 1 year ago

kk-cheng-1024 commented 2 years ago

如何实现 类似 tk.mybatis 中的 @KeySql(genId = SnowflakeGenId.class) 一样的功能

abel533 commented 2 years ago

先在service层封装吧

kk-fan commented 2 years ago

同求tk.mybatis 中的 @KeySql 使用 @KeySql(genId = SnowflakeGenId.class) 就可以不配置配置 sharding 的 key-generator 属性了 还有一个需求公司表有业务主键和逻辑主键 之前在使用通用mapper的时候只需要在业务主键上添加 @KeySql(genId = UUIDGenId.class) 很方便

abel533 commented 1 year ago

后续看看能不能给mybatis提交个可以自定义主键生成器的方案。

abel533 commented 1 year ago

provider中已经实现,将会发布新版本