Just to remember the strategies available in JPA for id generation. In most cases, AUTO will work fine as in
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
Sometimes AUTO does not work. Use IDENTITY for a database that supports autoincement columns and SEQUENCE for a database that supports sequences. Few databases require TABLE
- AUTO: Automatically choose a strategy
- IDENTITY: Use autoincrement on identiy column
- SEQUENCE: Use sequence, see @SequenceGenerator.
- TABLE: Use table, see @TableGenerator.