aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate: id generator for column in composite key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate: id generator for column in composite key" Watch "hibernate: id generator for column in composite key" New topic
Author

hibernate: id generator for column in composite key

sachin y deshpande
Greenhorn

Joined: May 12, 2004
Posts: 20
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

Joined: Apr 14, 2004
Posts: 10336

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?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
Consider Paul's rocket mass heater.
 
subject: hibernate: id generator for column in composite key