-->
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: Advise with 4 elements relationship - Newbie
PostPosted: Tue May 10, 2005 4:49 am 
Beginner
Beginner

Joined: Tue May 10, 2005 4:18 am
Posts: 29
Hello to all here
I am quite a newbie, and need to face in my first Hibernate task, with a complicated mapping, which I cannot seem to decided how to implement.
If you could help me out of your experience, I would be very thankful.

I have 4 main entities : Person, Event, Image and Geo-Object.

Now - they are all connected to one another in a many-to-many relationship in a 4 way relationship table.
This table has 5 columns - 1 for each of the object's id (PersonID, EventID etc) which can hold NULL as well, and one column which holds the type of the relationship.

I.E. A person could be connected to an Event in a "part of" relationship, but also in connected to other event in another type of relationship.

In my application, when I am showing the Person's details, I am also showing the related Events, and write the type of relationship every Event has with this Person.

These are some rows from the table:

idImage | idEvnt | idGO | idPers | reltyp
-------------+-------------+-------------+-------------+-------
| 579927079 | | 2067197751 | 46
| 1997507902 | 96 | | 35
| 510871494 | | -2115704173 | 45
| 1701742053 | 141 | | 35



It is important to say that it is rare that the 4 elements are connected together (I.E. a row in the relationship table where all columns have values). Most of the time it is just 2-3 columns that are with value.

I hope the schema is understood.

Now - I do not know whether I should implement this as a 4 Way association (since it is rare that there is really a 4 way relationship) as explained here : http://www.xylax.net/hibernate/ternary.html or maybe I should implement this as the "Employer/Employee" example in the reference (section 18.1) - but with many small "Employment" entities (As I need one for Person-Event, one for Person-Image, one for Person-GeoObject etc...) .

I really cannot decide, and cannot seem to find the appropriate example.

Maybe any of you came across such example ?

Thank you !


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.