• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - Autogenerate composite keys

 
Chitra Raji
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to autogenerate one of the components of the composite primary key using hibernate configuration file ?\

I have a table with 3 columns forming a unique key of the table. Is there a way to generate one of them using autogeneration in configuration file?

Thanx in advance.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably not, because once you go beyond the surrogate key primary key solution, how is Hibernate supposed to figure out what you want. Now if the composite key contains the surrogate key then it would be autogenerated, and the database is the one responsible for making the key/index with the three fields for you.

Usually, from a database design standpoint, you always want to create a non-business logic primary key that is filled in using a sequence table.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic