表“acme\u ms.hibernate\u sequence”不存在

csbfibhn  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(349)

我们正在尝试将我们的微服务迁移到springboot2,目前,我们使用的是springboot1.5.6.release。
在迁移过程中,我们发现我们的微服务部分中断,在日志文件中我们发现以下错误:
com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:表“acme\u ms.hibernate\u sequence”不存在
目前我们的应用程序中只存在一个域类:

@Getter
@Setter
@ToString
@Entity
@Table(name = "acme_ms_card_details")
public class CardDetails {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String cardType;
}

我们发现这个问题与 GeneratedValue 策略类型,我们尝试将策略更改为 GenerationType.IDENTITY 错误消失了。
所以,我们现在的问题是:为什么使用SpringBoot1.5 GenerationType.AUTO 很好地工作,但在迁移到SpringBoot2之后, GenerationType.AUTO 一点用都没有。
什么发生了重大变化?
注意:作为一个数据库,我们使用的是mysql。

c3frrgcw

c3frrgcw1#

springboot1.5.6使用hibernate5.0.12.final,而springboot2使用hibernate5.2.12.final,新的hibernate版本有一个中断的更改 strategy = GenerationType.AUTO .
您需要添加以下属性 hibernate.id.new_generator_mappingstrue 恢复向后兼容性。
hibernate 5 sequencegenerator未给出正确的值

rjjhvcjd

rjjhvcjd2#

你需要改变 @GeneratedValue(strategy = GenerationType.AUTO)@GeneratedValue(strategy = GenerationType.IDENTITY) .

相关问题