aspose file tools*
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate + Ternary Relation" Watch "Hibernate + Ternary Relation" New topic
Author

Hibernate + Ternary Relation

Babu Mehrunnesa
Greenhorn

Joined: Dec 18, 2008
Posts: 9
Hi
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_Artifact
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_Artifact_Status
Participant_participantId | Artifact_artifactId | Status_statusId
p1 a1 s1
p1 a2 s1
p2 a1 s2
p2 a2 s1

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

@ManyToMany
private List<Artifact> artifact ;

...
}
Artifact.java

@Entity
public class Artifact implements Serializable {
@Id
private Long artifactId;
...
}

Status.java
@Entity
public class Status implements Serializable {
@Id
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: 1707
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.


cmbhatt
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

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


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate + Ternary Relation