-->
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.  [ 5 posts ] 
Author Message
 Post subject: One-to-one mapping with composite id
PostPosted: Tue Jun 15, 2004 3:58 pm 
Newbie

Joined: Tue Jun 15, 2004 3:52 pm
Posts: 4
Having some difficulty figuring out how to correctly map my tables. The table structure is as follows

Code:
Table A {
   key{
     prop1
     prop2
     prop3
  }
}

Table B {
  key {
    prop1
    prop2
  }
}

Table A has a 3 property composite key and table B has a 2 property composite key. Their relationship falls on prop1 and prop2 from each table. I've read the documentation about how to define a one-to-one mapping but I can't figure out how to do the mapping with composite keys that have different number of properties.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 2:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Sorry you cannot do - they need the same key.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 2:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You will be able to do a many-to-one though


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 1:45 pm 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
I also have this kind of issue.

Even with a key componentId, It is not possible to do a one-to-one relationship ?

Code:
<composite-id name="id"
   class="TableBId">
   <key-property name="prop1"
      <column name="prop1"/>
   </key-property>
   <key-property name="prop2"
      <column name="prop2"/>
   </key-property>
</composite-id>



Table A {
key{
TableBId
prop3
}
}


Table B {
key {
TableBId
}
}

Thanks

Etienne.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 2:19 pm 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
I just realized that. My post is a non-sense.

If the prop3 doesn't descriminate on the object, it should not be part of the primary key! In the other side, if it must be part of the primary key (to descriminate the object), in means that you have a one-to-many relationship.

Etienne
Montreal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.