This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes hibernate mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate mapping" Watch "hibernate mapping" New topic
Author

hibernate mapping

Nital Chandel
Greenhorn

Joined: Jun 20, 2008
Posts: 1
I have one Table1(parent table) which is having one primary key column (id) and two other columns (code_type and code_value) combination of both is unique.

Now another table Table2, which is a child table, has column (prob_type) which is referencing Table1 column (code_value), and NOT the primary key (id).

I dont think that there is any solution from DB point of view. Is there some property in Hibernate which I can use so that both the tables can be mapped or related through Hibernate mapping files?
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
A foreign key may reference any unique column(s) of the target table, and not necessarily the primary key.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate mapping
 
Similar Threads
Hibernate many-to-one composite key as foreign key
one-to-many mapping with table having no primay key
Composite Foreign Key that maps to Unique Constraint
Hibernate: Different Join in Save() and Get()
Problem with joining of two tables with Hibernate