-->
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: Cross reference table of 3 tables: How to do it ?
PostPosted: Tue Mar 15, 2005 5:32 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
Hi All,

I am using Hibernate 2.1, Middlegen 2.1 with Oracle 9i. I have 3 tables:
Table A with A_id as primary key
Table B with B_id as primary key
Table C with C_id as primary key
I also defined a cross reference table called Table D with all three primary keys as its composite key.

I defined a table D in Middlegen's Ant task as follows:
< table name="D" />

Id di not define many2many tag to define it as a link table as it is a link tables of 3 tables instead of two.

Can someone please let me know if it is correct ? How would you define a link table made up of 3 tables ?

In order to add a record table A, I am making a call as:
session.save(objA);

In order to make a reacord in a link table D, I am calling:
session.save(objB);
DPK dpk = new DPK(A_id, B_id, C_id);
D objD = new D(dpk);
session.save(objD);

Table C is a lookup table.

I am getting a problem while retrieving object A, it does not return all its associated table D records.

Your help will be greatly appreciated.

Thanks
Ron


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 5:50 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
Ternary associations: http://www.hibernate.org/hib_docs/v3/reference/en/html/collections.html#collections-ternary


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.