mysqlhibernatejpa

Jpa id generation strategy, @id default is auto , mysql default is IDENTITY, but I found that a hibernate_sequence table was generated, why?


Jpa id generation strategy, @id default is auto , mysql default is IDENTITY, but I found that a hibernate_sequence table was generated, why?


Solution

  • This issue occurs when 'combining' Hibernate 5 and MySQL. See this article to read more about this.

    Use the following mapping to solve this.

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")
    private Integer id;