JPA annotations to define entities, use @id to annotate primary key attributes. If the database primary key is self-growing, you need to add an annotation @generatedvalue, i.e.:
1 @GeneratedValue (strategy=generationtype.identity)2 @Id3 private String ID;
PS: The Strategy property of the @GeneratedValue annotation provides four values:
–auto: The primary key is controlled by the program, which is the default option and is not set.
–identity: The primary key is automatically generated by the database, that is, the way the database ID is grown, which is not supported by Oracle.
–sequence: The primary key is generated through the sequence of the database, and the sequence name is specified by the @sequencegenerator annotation, which is not supported by MySQL.
–table: Generates a primary key from a specific database table, which makes it easier for the application to migrate to the database.
JPA's primary key self-growth annotation settings in Java