Advertisement
Guest User

Untitled

a guest
Jan 26th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. package softuniBlog.entity;
  2.  
  3. import javax.jws.soap.SOAPBinding;
  4. import javax.persistence.*;
  5. import java.util.HashSet;
  6. import java.util.Set;
  7.  
  8. @Entity
  9. @Table(name = "users")
  10. public class User {
  11.  
  12. private Integer id;
  13.  
  14. private String email;
  15.  
  16. private String fullName;
  17.  
  18. private String password;
  19.  
  20. private Set<Role> roles;
  21.  
  22. private Set<Images> images;
  23.  
  24. private Set<User> followingUser;
  25.  
  26. private String profilePicture;
  27.  
  28. public User(String email, String fullName, String password) {
  29. this.email = email;
  30. this.password = password;
  31. this.fullName = fullName;
  32.  
  33. this.roles = new HashSet<>();
  34. this.images = new HashSet<>();
  35. this.followingUser = new HashSet<>();
  36. }
  37.  
  38. public User() {
  39. }
  40.  
  41. @Id
  42. @GeneratedValue(strategy = GenerationType.IDENTITY)
  43. public Integer getId() {
  44. return id;
  45. }
  46.  
  47. public void setId(Integer id) {
  48. this.id = id;
  49. }
  50.  
  51. @Column(name = "email", unique = true, nullable = false)
  52. public String getEmail() {
  53. return email;
  54. }
  55.  
  56. public void setEmail(String email) {
  57. this.email = email;
  58. }
  59.  
  60. @Column(name = "fullName", nullable = false)
  61. public String getFullName() {
  62. return fullName;
  63. }
  64.  
  65. public void setFullName(String fullName) {
  66. this.fullName = fullName;
  67. }
  68.  
  69. @Column(name = "password", length = 60, nullable = false)
  70. public String getPassword() {
  71. return password;
  72. }
  73.  
  74. public void setPassword(String password) {
  75. this.password = password;
  76. }
  77.  
  78. @ManyToMany(fetch = FetchType.EAGER)
  79. @JoinTable(name = "users_roles")
  80. public Set<Role> getRoles() {
  81. return roles;
  82. }
  83.  
  84. public void setRoles(Set<Role> roles) {
  85. this.roles = roles;
  86. }
  87.  
  88. public void addRole(Role role) {
  89. this.roles.add(role);
  90. }
  91.  
  92. @OneToMany(mappedBy = "user")
  93. public Set<Images> getImages() {
  94. return images;
  95. }
  96.  
  97. public void setImages(Set<Images> images) {
  98. this.images = images;
  99. }
  100.  
  101. @ManyToMany(cascade = CascadeType.ALL)
  102. @JoinTable(name = "user_following", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "following_id", referencedColumnName = "id"))
  103. public Set<User> getFollowingUser() {
  104. return followingUser;
  105. }
  106.  
  107. public void setFollowingUser(Set<User> followingUser) {
  108. this.followingUser = followingUser;
  109. }
  110.  
  111. public void addFollow(User user) {
  112. this.followingUser.add(user);
  113. }
  114. @Column(name = "profilePicturePath", nullable = false)
  115.  
  116. public String getProfilePicture() {
  117. return profilePicture;
  118. }
  119.  
  120. public void setProfilePicture(String profilePicture) {
  121. this.profilePicture = profilePicture;
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement