Generationtype identity jpa mysql code example
Example: jpa generationtype sequence mysql
In Dec 2020, you still can’t use this strategy (SEQUENCE) with a MySQL database.
It requires a database sequence, and MySQL doesn’t support this feature.
If you’re working with a MySQL database, you should always use
GenerationType.IDENTITY. It uses an autoincremented database column and
is the most efficient approach available. You can do that by annotating
your primary key attribute with
@GeneratedValue(strategy = GenerationType.IDENTITY).