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

GeneratedValue Annotation

 
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 would be the difference between TABLE and SEQUENCE generation stratergies? Both make use of a generator table. Please help guys!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both make use of a generator table.

No, only the TABLE strategy uses a table. The SEQUENCE startegy uses a database sequence (like this).
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe...
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, why we don't have a generator attribute for @GeneratedValue annotation for GenerationType.IDENTITY?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some database servers, like SqlServer, use identity columns (like this). In this case, your are not getting the key from a different table or from a create sequence (in which case you'd have to tell which table/sequence you're using), but you are using an identity column of the entity itself. So you don't need to tell which generator to use.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Christophe!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic