Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate: id generator for column in composite key

 
sachin y deshpande
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table which looks like this:
t1col1 not null
t1col2 auto generated indentity
t1col3
and (composite) primary key = t1col1, t1col2

i created a hbm which looks like:

Problem is t1col2 is auto generated. How should this be specified in hbm?
Thanks in advance

[ Edited to use code tags - Paul Sturrock ]
[ April 13, 2007: Message edited by: Paul Sturrock ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With composite keys your only key generation strategy is "assigned". Neither Hibernate nor the database can know anything about the business logic you require to generate your composite key.

That aside, if your composite key contains an identity field (which will have all the properties of a surrogate key) why are you using a composite key at all?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic