Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. package com.home.lukasz.SpringChatBackend.models;
  2.  
  3. import com.fasterxml.jackson.annotation.JsonIgnore;
  4.  
  5. import javax.persistence.*;
  6. import java.util.HashSet;
  7. import java.util.Set;
  8.  
  9. @Entity
  10. @Table(name = "shadows")
  11. public class User {
  12.  
  13. @Id
  14. @Column(name = "id", unique = true, nullable = false)
  15. @GeneratedValue(strategy = GenerationType.IDENTITY)
  16. private Long id;
  17.  
  18. @Column(name = "username")
  19. private String username;
  20.  
  21. @JsonIgnore
  22. @Column(name = "password")
  23. private String password;
  24.  
  25. @Column(name = "email")
  26. private String email;
  27.  
  28. @ManyToMany(fetch = FetchType.EAGER)
  29. @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"),
  30. inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "role_id"))
  31. private Set<Role> roles = new HashSet<>();
  32.  
  33. public Long getId() {
  34. return id;
  35. }
  36.  
  37. public void setId(Long id) {
  38. this.id = id;
  39. }
  40.  
  41. public String getUsername() {
  42. return username;
  43. }
  44.  
  45. public void setUsername(String username) {
  46. this.username = username;
  47. }
  48.  
  49. public String getPassword() {
  50. return password;
  51. }
  52.  
  53. public void setPassword(String password) {
  54. this.password = password;
  55. }
  56.  
  57. public String getEmail() {
  58. return email;
  59. }
  60.  
  61. public void setEmail(String email) {
  62. this.email = email;
  63. }
  64.  
  65. public Set<Role> getRoles() {
  66. return roles;
  67. }
  68.  
  69. public void setRoles(Set<Role> roles) {
  70. this.roles = roles;
  71. }
  72.  
  73. @Override
  74. public String toString() {
  75. return "User{" +
  76. "id=" + id +
  77. ", username='" + username + '\'' +
  78. ", password='" + password + '\'' +
  79. ", email='" + email + '\'' +
  80. //", role='" + roles.iterator().next().getRoleName() + '\'' +
  81. '}';
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement