MySQL:
在实体类主键字段上使用:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY,generator = "JDBC")
PostgreSQL:
在实体类主键字段上使用:
@Id
@KeySql(useGeneratedKeys = true)
@Column(name = "id",insertable = false)
稍微有点区别,记录一下,另外 PostgreSQL使用Mybatis Generator生成接口和映射xml文件时,insert和insertSelective方法生成的主键获取策略有问题,selectKey里边就一个PostgreSQL内容
需要自己改动一下
推荐使用TKMabatis+lombok这种方式