-->
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.  [ 5 posts ] 
Author Message
 Post subject: Ternary mapping : design question
PostPosted: Mon Nov 17, 2003 10:30 am 
Newbie

Joined: Tue Oct 28, 2003 5:35 am
Posts: 7
Hi Everybody,

I'm an Hibernate newbie from now 2 weeks and I'm still confused about how to cleary design ternary associations.

Here's the asssociation I want to map :

Code:
ObjectA <--(0,n) -->[ternary_association] <-- (1,1) --> RightType
                            |
                          (0,n)
                            |
                           User


    - An ObjectA can be manipulated by several Users,
    - A User can manipulated several ObjectA,
    - But one User has a unique RightType for a ObjectA.


So it means (but maybe I'm wrong) that I should have into the entity table a unique composed key, composed of the foreign keys of ObjectA and User, plus a many-to-one association to RightType.

Can somebody tell me how to do this mapping ?
Better approach ?

Thanks for any help,


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 11:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There are three different approaches:

* make the link an entity class
* make the link a composite-element
* make it a Map


which one would you like?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 11:29 am 
Newbie

Joined: Tue Oct 28, 2003 5:35 am
Posts: 7
gavin wrote:
There are three different approaches:

* make the link an entity class
* make the link a composite-element
* make it a Map


which one would you like?


Well ... to be honest (And I apologize for this) I don't really know as I don't see what are the pros and cons of each of them.

I will say either as a entity or as a composite-element. What is exactly the difference ?

(P.S: thanks for your quick reply)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 7:07 pm 
Newbie

Joined: Tue Oct 28, 2003 5:35 am
Posts: 7
philippe wrote:
gavin wrote:
There are three different approaches:

* make the link an entity class
* make the link a composite-element
* make it a Map


which one would you like?


Well ... to be honest (And I apologize for this) I don't really know as I don't see what are the pros and cons of each of them.

I will say either as a entity or as a composite-element. What is exactly the difference ?

(P.S: thanks for your quick reply)


Anybody has any idea ? or am I stupid ?


Top
 Profile  
 
 Post subject: Suggestion
PostPosted: Sat Jan 10, 2004 3:08 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Hi Philippe,

IF you are stupid, you are certainly NOT alone on this. I haven'r been able to find a clear and consice description of the differences in usage and so on for the different ternary mapping strategies.

What I learned so far (I'm a newbie) is that, for cla A, B and C:

A contains a map with B as index, it will only be possible to enter ONE C for each unique B, not a collection of C:s.

Have you seen the excellent
http://www.xylax.net/hibernate/
?
Check out "Ternary association", maybe that's a good strategy for your perticiular needs (if you haven't solved them already)

Sincerely,

/C


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