This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Composite key mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Composite key mapping" Watch "Composite key mapping" New topic
Author

Composite key mapping

Pallu Sagar
Greenhorn

Joined: Dec 04, 2009
Posts: 16
I have Composite Primary key and foreign key which is also composite key. one of the column is same...

i.e. Table Group has composite Id PRIMARY KEY(gId, cId) [ Where cId is primary key of other table ]

Now Table GroupMember has composite primary key PRIMARY KEY(gmid, cId ) [ Where cId is primary key of other table ].

GroupMember also has foreign key fkgroup REFERENCES Group(gid, cId) (which is composite key as mentioned above]

Now, when I attemt to save GroupMember instance, foreign key (fkgroup) is not inserted. In many-to-one relationship I cannot set insert=true because cId is part of primary key for both GroupMember and Group Table.

How do I persist column fkgroup of GroupMemeber table?


-Sagar
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Composite key mapping
 
Similar Threads
Hibernate many-to-one composite key as foreign key
Composite Primary key and JDBC
Hibernate Mapping- composite id (pk+ foreign key)
[Help] Hibernate composite key plus foreign key with cascade insert.
database design help needed