-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: composite problem
PostPosted: Fri Sep 26, 2003 11:02 am 
Newbie

Joined: Fri Sep 26, 2003 10:46 am
Posts: 6
Hi All,
I have 2 tables
1. Dept Table where in i have deptid,divid,dname,address as columns
2. Divsion table where in i have deptid,divid,divname,address, as columns

How can i map these two tables in .xml using one-to-one relation ship?
(generated .hbm.xml file will be of more help)

I)the Dept table has primary keys deptid,divid
II)the Divsion table has primary keys deptid,divid (these are the foreign keys)

and also one more question do all the tables need to have primary key?if yes why?

regards
Reddy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 1:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Column keys are declared in there own group.
eg one-to-one (one side) :

<many-to-one
name="bid"
class="org.hibernate.workshop.toolset.Bid"
>
<column name="FIRST_ID" />
<column name="SECOND_ID" />
</many-to-one>


Then on the other side.
<one-to-one
name="item"
class="org.hibernate.workshop.toolset.Item"
outer-join="auto"
property-ref="bid"
/>

Where the property ref refers to the foreign key property.
NOTE: Hibernate 2.1 required for this mapping.

Primary key is best otherwise need to do equals/hashcode over the full set.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.