• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ID Generation using Identity

 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic