Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 29fb202

Browse files
author
Rajeev Kumar Singh
committed
Added @onDelete Cascade to child entity
1 parent f6031f1 commit 29fb202

File tree

1 file changed

+4
-0
lines changed
  • src/main/java/com/example/postgresdemo/model

1 file changed

+4
-0
lines changed

src/main/java/com/example/postgresdemo/model/Answer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.example.postgresdemo.model;
22

33
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import org.hibernate.annotations.OnDelete;
5+
import org.hibernate.annotations.OnDeleteAction;
6+
47
import javax.persistence.*;
58

69
@Entity
@@ -20,6 +23,7 @@ public class Answer extends AuditModel {
2023

2124
@ManyToOne(fetch = FetchType.LAZY)
2225
@JoinColumn(name = "question_id", nullable = false)
26+
@OnDelete(action = OnDeleteAction.CASCADE)
2327
@JsonIgnore
2428
private Question question;
2529

0 commit comments

Comments
 (0)