posted 8 years ago
If you read about both annotations, you'll see that @TableGenerator uses a table to hold primary keys. The next primary key value will be taken from that table and incremented. @SequenceGenerator uses a database sequence (like Oracle sequences) to generate primary keys. Setting the generation type (GenerationType) to AUTO will let the persistence provider choose for you which type to use. You can implicitly tell it which type to use via either IDENTITY, TABLE or SEQUENCE. If you do so, you have to check that your persistence provider supports the GenerationType.