Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 34b7c71

Browse files
author
Rajeev Kumar Singh
committed
Added @onDelete Cascade to child entity
1 parent 8cba4bc commit 34b7c71

File tree

1 file changed

+3
-0
lines changed
  • jpa-one-to-many-demo/src/main/java/com/example/jpa/model

1 file changed

+3
-0
lines changed

‎jpa-one-to-many-demo/src/main/java/com/example/jpa/model/Comment.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import javax.persistence.*;
66
import javax.validation.constraints.NotNull;
7+
import org.hibernate.annotations.OnDelete;
8+
import org.hibernate.annotations.OnDeleteAction;
79

810
/**
911
* Created by rajeevkumarsingh on 21/11/17.
@@ -21,6 +23,7 @@ public class Comment extends AuditModel {
2123

2224
@ManyToOne(fetch = FetchType.LAZY)
2325
@JoinColumn(name = "post_id", nullable = false)
26+
@OnDelete(action = OnDeleteAction.CASCADE)
2427
@JsonIgnore
2528
private Post post;
2629

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /