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 many-to-many with idbag, composite,.. ?
PostPosted: Tue May 18, 2004 11:49 am 
Newbie

Joined: Mon Nov 17, 2003 12:06 pm
Posts: 1
Hello,

after searching the documentation and forum posts I am still stuck with
the question how to map a many-to-many relationship between two tables
with the relationship table having a primary key of its own and extra attributes:
Code:
T_MANY1              T_RELATION                T_MANY2

MANY1_ID  (PK)       RELATION_ID (PK)          MANY2_ID  (PK)
FOO       (ATTRIB)   FK_TO_MANY1 (FK1)         BAR       (ATTRIB)
                     FK_TO_MANY2 (FK2)
                     STATUS      (ATTRIB)
                     DATE        (ATTRIB)


I've learned I could use the <idbag>-tag introduced in 6.13. of the hibernate reference with the many-to-many tag, but then, I can't figure out how to adress the extra fields STATUS and DATE.

Alternatively, trying to map the above with
Code:
...
<idbag>
...
        <composite-element class=" ...>
            <property name="status" .../>
            <many-to-one .../>
        </composite-element>
</idbag>
I do not understand wether I have to do this in the mappings of both outer tables and wonder which java classes to generate/write. Until now, I ended up with four classes mapping the above relation, leaving me with a feeling of doubt....

Could someone give me some insight or even better, provide an understandable example of two mapping files, please?

Thanks,
Markus


Top
 Profile  
 
 Post subject: any progess?
PostPosted: Tue Jun 01, 2004 8:07 am 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
Hi Markus,

I'm facing with a situation like yours. Can you help me how to map this 3 tables?

Thanks in advance,
Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 8:12 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
You can use composed element, or instead of a many to many you can use 2 many to one relationship bidirectionnal.
Look at the hibernate reference in examples chapter "Product, Customer and Order".


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.