-->
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 extra attribute in mapping table
PostPosted: Tue May 16, 2006 6:01 pm 
Newbie

Joined: Tue May 16, 2006 5:48 pm
Posts: 6
I have a simple many-to-many user-company relationship, but I also need to store an extra attribute at the companyUser level.

Can I put the extra attribute in the many-to-many companyUser mapping table and still get access to it?

I have tried modelling the relationship as two relationships - many-to-one, one-to-many, and then managing the mapping table manually. But doing that seems confusing with both table columns and mapped objects in the mapping table.

Any advice? I have only been using Hibernate a few weeks, so there may be an obvious solution I am missing.

Thanks

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 6:44 pm 
Regular
Regular

Joined: Thu Jul 08, 2004 1:21 pm
Posts: 68
Location: Recife - Pernambuco - Brazil
You could use composite-element to mapping these relantionship. It looks like what you do right now, but more concise with hibernate idiom.

Kind Regards,

_________________
Marcos Silva Pereira
http://blastemica.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 6:57 pm 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
Martin,

Section 7.3.2 in the reference document describes bi-directional mapping.
You could use an intermediate association class as the many-to-many element type.

Section 7.3.3 talks about ternary associations, modelled for example
as a Map (Company in your case, keyed on User) having the extra attributes
you're looking for as the mapped value.

HTH

_________________
Cheers,

Bonny

please don't forget to rate :)


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.