-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping Association : 1..1 <--> 0..1
PostPosted: Mon Sep 27, 2004 12:35 pm 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
I have a parent child relationship

A (1..1) --> (0..1)B

Class A
{
private B b;
}


I dont want a B_ID reference in the 'A' DB table. just the A_ID FK in the 'B' table.

In the mapping of B, I have:

<many-to-one name="A' column="A_ID" class="A" not-null="true"/>
that takes care of the ownership of B (and the FK from the B back to A)

Is it possible to somehow have class A mapped, and only call the setB( B b ) method if there is an entry in table B with the ID of A, otherwise the object reference in A will remain null?

Ive seen the examples in Hibernate in Action as well as in the ref guide, but they all have a Set<B> mapped in class A


Nick


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 27, 2004 12:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use <one-to-one property-ref/>. There is an example in the reference manual, and in HiA


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 27, 2004 12:39 pm 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
Thanks Gavin.

Do you have a page ref for HiA or even a chapter?

Nick


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