Advertisement
Guest User

Untitled

a guest
May 8th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. package com.hellokoding.account.model;
  2.  
  3.  
  4. import javax.persistence.*;
  5. import java.util.List;
  6. import java.util.Set;
  7.  
  8. @Entity
  9. @Table(name = "user")
  10. public class User {
  11. private Long id;
  12. private String username;
  13. private String password;
  14. private String passwordConfirm;
  15. private Set<Role> roles;
  16. // private Reservation reservation;
  17.  
  18. @OneToMany(mappedBy="user")
  19. private List<Reservation> reservations;
  20. @Id
  21. @GeneratedValue(strategy = GenerationType.AUTO)
  22. public Long getId() {
  23. return id;
  24. }
  25.  
  26. public List<Reservation> getReservations() {
  27. return reservations;
  28. }
  29.  
  30. public void setReservations(List<Reservation> reservations) {
  31. this.reservations = reservations;
  32. }
  33.  
  34. // @OneToMany(
  35. // cascade = CascadeType.ALL,
  36. // orphanRemoval = true
  37. // )
  38. // @JoinColumn(name = "res_id")
  39. // public Reservation getReservation() {
  40. // return reservation;
  41. // }
  42. //
  43. // public void setReservation(Reservation reservation) {
  44. // this.reservation = reservation;
  45. // }
  46.  
  47.  
  48. public void setId(Long id) {
  49. this.id = id;
  50. }
  51.  
  52. public String getUsername() {
  53. return username;
  54. }
  55.  
  56. public void setUsername(String username) {
  57. this.username = username;
  58. }
  59.  
  60. public String getPassword() {
  61. return password;
  62. }
  63.  
  64. public void setPassword(String password) {
  65. this.password = password;
  66. }
  67.  
  68. @Transient
  69. public String getPasswordConfirm() {
  70. return passwordConfirm;
  71. }
  72.  
  73. public void setPasswordConfirm(String passwordConfirm) {
  74. this.passwordConfirm = passwordConfirm;
  75. }
  76.  
  77. @ManyToMany
  78. @JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
  79. public Set<Role> getRoles() {
  80. return roles;
  81. }
  82.  
  83. public void setRoles(Set<Role> roles) {
  84. this.roles = roles;
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement