-->
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.  [ 7 posts ] 
Author Message
 Post subject: One-to-one mapping with multiple tables
PostPosted: Tue Oct 21, 2003 2:18 am 
Beginner
Beginner

Joined: Thu Sep 25, 2003 10:30 am
Posts: 23
Location: india
Hi,
I got this one table which have got one-to-one mapping with many master tables. How do I go about doing it. Coz as far as I know the parent and the child share the same relationship in One-to-one mapping. Does anybody have solution to this problem
The other way I can find is mapping it as one-to-many is it right way
regards
prasad chandrasekaran


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 3:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Prety confuse. Can you explain this with an small example ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: One-to-one mapping with multiple tables
PostPosted: Tue Oct 21, 2003 5:00 am 
Beginner
Beginner

Joined: Thu Sep 25, 2003 10:30 am
Posts: 23
Location: india
I got this BasicPolicyDetail table which has got one to one relationship with agent, product and customer.
So the BasicPolicyDetail would be having agentid, productid and customerid. The question is how do I map the relationship.
One thing can be done is I can keep agentid, productid and customerid as composite primary key class.
But there is AdvancePolicyDetail class which extends the BasicPolicyDetail.

thanks
regards
prasad chandrasekaran


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 8:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Each end of one to one must have the same pk id than the BasicPolicyDetail object. The generator can be of foreign type to ensure automatic matching identifiers
http://www.hibernate.org/118.html#A9
And the next question is:
Can you use a unique key other than the PK ? Yes till Hibernate 2.1beta1
Code:
<one-to-one name="employee" class="Employee" property-ref="person"/>

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 4:24 pm 
Beginner
Beginner

Joined: Thu Oct 09, 2003 3:42 pm
Posts: 22
Quote:
Can you use a unique key other than the PK ? Yes till Hibernate 2.1beta1


Is this because it is broken in beta 1 or because the behavior is being removed?

Could you explain the property-ref attribute. It does not seem to appear in either the reference doc or Hibernate mapping DTD

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 4:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
He means "since", not "until".


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 5:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gavin wrote:
He means "since", not "until".

Hum yes, sorry.

Here is a sample of property-ref http://forum.hibernate.org/viewtopic.php?t=924804&start=0&postdays=0&postorder=asc&highlight=propertyref

_________________
Emmanuel


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