-->
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.  [ 10 posts ] 
Author Message
 Post subject: 0..1 Mapping using a separate link table
PostPosted: Thu Nov 04, 2004 7:35 pm 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
Hibernate version:2.1.6

I have the following objects:

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

I need to store A's value of B in a separate table (for data integrity - so that we can make use of non-null fields and Foreign Keys).

We need three tables:

A_TBL
====
ID PRIMARY KEY,
PROPERTY_ID

B_TBL
====
ID PRIMARY KEY

A_B_TBL
======
A_ID (FK)
B_ID (FK)
PROPERTY_ID (stored for business data integrity reason so we can add a unique constraint)

Many A's could reference the same B
One A can have zero or 1 B

What is the best way to map this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 8:04 pm 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
I omitted that:

In A.java

is has a nullable property 'B'


I can map this using Collections - but is there a way to map 0..1 mapping like this using an association table?

Nick


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 1:59 pm 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
Is there anyway to achieve this without having to make a separate A_B java class (and adding its associated mapping file) ?

This is a fairly common DB data integrity pattern for 0..1 relationships - if 2.1.6 doesnt support it directly, are there plans for H3 to provide this support?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 8:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
In H3 road map
Quote:
ability to map association tables as having one-to-many multiplicity at the object level


For now, put a private collection and do

Code:
getB() {
  return (B) myHiddenColl.get(0);
}

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 10:15 am 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
Thanks. That's what I came up with over the weekend.

With regards to the H3 roadmap - is there a list of features, and whether or not they are implemented yet? (Along with an estimate of when a beta is likely?)

Thanks again

Nick


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 10:17 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Uhm, that is what is _in_ the road map actually :)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 10:28 am 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
Thanks Christian - I sorta understand what the roadmap is - I was asking where it was online {:-)

Nick


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 10:30 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Its in the main navigation on the left side of hibernate.org ;)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 10:33 am 
Regular
Regular

Joined: Fri Sep 03, 2004 2:01 pm
Posts: 51
So it is {:-) Any more info on the first beta release date?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 10:35 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I think "this year" is a good enough guess at this point, some issues are still open and in the process of being resolved.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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