-->
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.  [ 1 post ] 
Author Message
 Post subject: "transitive" associations
PostPosted: Wed Mar 10, 2010 2:42 pm 
Newbie

Joined: Thu May 14, 2009 1:59 pm
Posts: 4
About 9 months ago, I had asked this question and got no feedback, so I thought I would try again. I've gotten away without having to do this, but if I could, it would be a huge help.

I have 3 tables, A,B and C. A is one to many with B, and B is one to many with C. These relationships are easy to map out. I thought the relationship I wanted was easy as well, but it appears not.

I want to have a property on A (say getCs()) that is mapped to all the Cs whose Bs are mapped to this A. For example:

Code:
A1 -- B11 -- C111
   |      \- C112
   \- B12 -- C121
          \- C122
A2 -- B21 -- C211
   |      \- C212
   \- B22 -- C221
          \- C222

A1.getCs() would return [C111, C112, C121, C122] and A2.getCs() would return [C211, C212, C221, C222].

Can anyone tell me how to do this, either with hibernate annotations, or with a mapping xml file, either case will be fine. I also do not care if the C objs have a getA() method.

Thank you!
DS


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.