File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate + Ternary Relation

 
Babu Mehrunnesa
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Babu HM" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic