Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between id generators

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

What is the prime difference between a @TableGenerator and a @SequenceGenerator and what they ultimately do is to generate a primary key for which the AUTO would do the same thing. Can you please help me differentiate the importance.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic