A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Object Relational Mapping
hibernate: id generator for column in composite key
sachin y deshpande
Joined: May 12, 2004
Apr 13, 2007 06:47:00
I have a table which looks like this:
t1col1 not null
t1col2 auto generated indentity
and (composite) primary key = t1col1, t1col2
i created a hbm which looks like:
<class name="Table1" table="TABLE1"> <composite-id> <key-property name="col1" column="t1col1" /> <key-property name="col2" column="t1col2" /> </composite-id> <property name="col3" column="t1col3" not-null="true" /> </class>
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 ]
Joined: Apr 14, 2004
Apr 13, 2007 07:17:00
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?
subject: hibernate: id generator for column in composite key
Relationship between two table having composite keys on both the sides
Hibernate Repeated column mapping problem
Hibernate: Different Join in Save() and Get()
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015