Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ID Generation using Identity

 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
Could you please give me some examples of cases that we should use GenerationType.IDENTITY for @GeneratedValue?
What database vendors do support it?

Thanks
daniel
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, in almost all situations, I wouldn't use it. My own feeling is if you use a database-neutral technology you shouldn't then restrict the set of databases you can use it against by relying on the database to generate primary keys. The only time I would use it is if the schema already exists, uses identity columns and cannot be changed.

Instead, I'd use some other generation strategy that is implemented by the application using a well understood algorithm seeded from the database, so always use ASSIGNED for the generaiton type.

According to the Hibernate documentation DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL support it, and I can't expand on that list.
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic