【问题标题】:MYSQL+ Spring Boot two table with same id (default auto increment) column not update properlyMYSQL Spring Boot 两个具有相同 id 的表(默认自动递增)列无法正确更新
【发布时间】:2017-05-26 02:46:33
【问题描述】:

我有两张桌子customerproduct。两者都包含一个公共列 id 作为主键并自动递增。

问题在于,在添加新条目时,它会从 customerproduct 中获取 id 列的最大值,而 product 中的 id 列的值最高,然后自动递增并添加新条目。

详细说明:customer id 中最高值为 7,product 中最高值为 5。

product添加条目时,将id值取8并添加新条目。

【问题讨论】:

    标签: mysql spring-boot


    【解决方案1】:

    开始使用
    “@GeneratedValue(strategy = GenerationType.AUTO)”注解使用如下

    @GeneratedValue(generator = "increment")

    @GenericGenerator(name = "increment", strategy = "increment")

    【讨论】:

      猜你喜欢
      • 2020-02-27
      • 1970-01-01
      • 2014-10-01
      • 2011-02-18
      • 2021-10-14
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多