I have the following two classes, one ReqCandAssociation can have many Comments and it is mapped like so. I need to figure out a way that when I delete a ReqCandAssociation it deletes all of its associated comments. Thanks
@Entity
@Table(name = "candidate_jobReq")
public class ReqCandAssociation implements Serializable {
@Id
private Integer candidateId;
@Id
private Integer jobId;
@Column(name = "reqStatus")
private String reqStatus;
@ManyToOne
@PrimaryKeyJoinColumn(name="candidateId", referencedColumnName="id")
private Candidate candidate;
@ManyToOne
@PrimaryKeyJoinColumn(name="jobId", referencedColumnName="id")
private JobReq jobReq;
public ReqCandAssociation(){
}
Second class
@Entity
@Table(name="comment")
public class Comment {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
@Column(name="commentText")
private String commentText;
@Column(name="commentDate")
private Date commentDate;
@ManyToOne
@PrimaryKeyJoinColumn(name="reqCandAssociationId", referencedColumnName="id")
private ReqCandAssociation reqCandAssociation;
@ManyToOne
@PrimaryKeyJoinColumn(name="userId", referencedColumnName="id")
private User user;