Skip to content

Commit 01cabd8

Browse files
author
Rajeev Kumar Singh
committed
Added some JPA optimizations
1 parent 6b91360 commit 01cabd8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

polling-app-server/src/main/java/com/example/polls/model/Choice.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Choice {
2020
@Size(max = 40)
2121
private String text;
2222

23-
@ManyToOne(fetch = FetchType.LAZY)
23+
@ManyToOne(fetch = FetchType.LAZY, optional = false)
2424
@JoinColumn(name = "poll_id", nullable = false)
2525
private Poll poll;
2626

polling-app-server/src/main/java/com/example/polls/model/Vote.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public class Vote extends DateAudit {
1515
@GeneratedValue(strategy = GenerationType.IDENTITY)
1616
private Long id;
1717

18-
@ManyToOne(fetch = FetchType.LAZY)
18+
@ManyToOne(fetch = FetchType.LAZY, optional = false)
1919
@JoinColumn(name = "poll_id", nullable = false)
2020
private Poll poll;
2121

22-
@ManyToOne(fetch = FetchType.LAZY)
22+
@ManyToOne(fetch = FetchType.LAZY, optional = false)
2323
@JoinColumn(name = "choice_id", nullable = false)
2424
private Choice choice;
2525

26-
@ManyToOne(fetch = FetchType.LAZY)
26+
@ManyToOne(fetch = FetchType.LAZY, optional = false)
2727
@JoinColumn(name = "user_id", nullable = false)
2828
private User user;
2929

0 commit comments

Comments
 (0)