This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate + Ternary Relation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate + Ternary Relation" Watch "Hibernate + Ternary Relation" New topic

Hibernate + Ternary Relation

Babu Mehrunnesa

Joined: Dec 18, 2008
Posts: 9
Am having 3 entity classes Participant(participantId-ID),
Artifact(artifactId-ID) & Status(StatusIs-ID, readStatus).
There is a @ManyToMany relationship b/w Participant -> Artifact.
As a result in mysql DB a new join_table Participant_Artifact got created.
The structure of the Join table is

Participant_participantId | Artifact_artifactId

My requirement is to add the read status per participantId/per ArtifactId.
i.e I need to create the ternary relationship b/w Participant_Artifact_Status. My Join Table should look like
Participant_participantId | Artifact_artifactId | Status_statusId
p1 a1 s1
p1 a2 s1
p2 a1 s2
p2 a2 s1

My Participant entity class looks like
public class Participant implements Serializable {
private Long userId;

private List<Artifact> artifact ;


public class Artifact implements Serializable {
private Long artifactId;
public class Status implements Serializable {
private Long statusId
@ManyToMany b/w Participant -> Artifact
Could some one pl tell me How I can build ternary association b/w
Participant -> Artifact -> Status
[ December 23, 2008: Message edited by: Babu Mehrunnesa ]
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710
Hi Babu,

Welcome to JavaRanch community!!!

Can you come up with what have you tried with this up till now?
Please post real scenario/example for ease in comprehending your problem.

Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2846

"Babu HM" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.

|Asking Good Questions|
I agree. Here's the link:
subject: Hibernate + Ternary Relation
jQuery in Action, 3rd edition