Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Difference between id generators

Ranch Hand
Posts: 10192
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
Posts: 14691
Eclipse IDE VI Editor Ubuntu
  • 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.
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic