File tree Expand file tree Collapse file tree
spring-security-oauth/src/main/java/org/baeldung/persistence/model Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import java .util .Date ;
44
5+ import javax .persistence .Column ;
56import javax .persistence .Entity ;
67import javax .persistence .GeneratedValue ;
78import javax .persistence .GenerationType ;
@@ -16,22 +17,26 @@ public class Post {
1617 @ GeneratedValue (strategy = GenerationType .AUTO )
1718 private Long id ;
1819
20+ @ Column (nullable = false )
1921 private String title ;
2022
23+ @ Column (nullable = false )
2124 private String subreddit ;
2225
26+ @ Column (nullable = false )
2327 private String url ;
2428
2529 private boolean sendReplies ;
2630
31+ @ Column (nullable = false )
2732 private Date submissionDate ;
2833
2934 private boolean isSent ;
3035
3136 private String submissionResponse ;
3237
3338 @ ManyToOne
34- @ JoinColumn (name = "user_id" )
39+ @ JoinColumn (name = "user_id" , nullable = false )
3540 private User user ;
3641
3742 public Post () {
Original file line number Diff line number Diff line change 11package org .baeldung .persistence .model ;
22
33import java .util .Date ;
4- import java .util .List ;
54
5+ import javax .persistence .Column ;
66import javax .persistence .Entity ;
77import javax .persistence .GeneratedValue ;
88import javax .persistence .GenerationType ;
99import javax .persistence .Id ;
10- import javax .persistence .OneToMany ;
1110
1211@ Entity
1312public class User {
@@ -16,6 +15,7 @@ public class User {
1615 @ GeneratedValue (strategy = GenerationType .AUTO )
1716 private Long id ;
1817
18+ @ Column (nullable = false )
1919 private String username ;
2020
2121 private String accessToken ;
@@ -26,9 +26,6 @@ public class User {
2626
2727 private boolean needCaptcha ;
2828
29- @ OneToMany (mappedBy = "user" )
30- private List <Post > posts ;
31-
3229 public User () {
3330 super ();
3431 }
@@ -81,14 +78,6 @@ public void setNeedCaptcha(boolean needCaptcha) {
8178 this .needCaptcha = needCaptcha ;
8279 }
8380
84- public List <Post > getPosts () {
85- return posts ;
86- }
87-
88- public void setPosts (List <Post > posts ) {
89- this .posts = posts ;
90- }
91-
9281 @ Override
9382 public int hashCode () {
9483 final int prime = 31 ;
You can’t perform that action at this time.
0 commit comments