Advertisement
Guest User

Untitled

a guest
May 14th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. package test;
  2.  
  3. import javax.persistence.*;
  4.  
  5. @Entity
  6. @Table(name = "USER_DATA", schema = "dbo", catalog = "LocalSchool")
  7. public class UserDataEntity {
  8. private int userId;
  9. private Integer privilegeId;
  10. private String username;
  11. private String password;
  12. private String email;
  13. private PrivilegeEntity privilegeByPrivilegeId;
  14.  
  15. public UserDataEntity() {
  16. }
  17.  
  18. public UserDataEntity(String username, String password) {
  19. this.username = username;
  20. this.password = password;
  21. }
  22.  
  23. @Id
  24. @GeneratedValue(strategy = GenerationType.IDENTITY)
  25. @Column(name = "userId")
  26. public int getUserId() {
  27. return userId;
  28. }
  29.  
  30. public void setUserId(int userId) {
  31. this.userId = userId;
  32. }
  33.  
  34. @Basic
  35. @Column(name = "privilegeId", insertable = false, updatable = false)
  36. public Integer getPrivilegeId() {
  37. return privilegeId;
  38. }
  39.  
  40. public void setPrivilegeId(Integer privilegeId) {
  41. this.privilegeId = privilegeId;
  42. }
  43.  
  44. @Basic
  45. @Column(name = "username")
  46. public String getUsername() {
  47. return username;
  48. }
  49.  
  50. public void setUsername(String username) {
  51. this.username = username;
  52. }
  53.  
  54. @Basic
  55. @Column(name = "password")
  56. public String getPassword() {
  57. return password;
  58. }
  59.  
  60. public void setPassword(String password) {
  61. this.password = password;
  62. }
  63.  
  64. @Basic
  65. @Column(name = "email")
  66. public String getEmail() {
  67. return email;
  68. }
  69.  
  70. public void setEmail(String email) {
  71. this.email = email;
  72. }
  73.  
  74. @Override
  75. public boolean equals(Object o) {
  76. if (this == o) return true;
  77. if (o == null || getClass() != o.getClass()) return false;
  78.  
  79. UserDataEntity that = (UserDataEntity) o;
  80.  
  81. if (userId != that.userId) return false;
  82. if (privilegeId != null ? !privilegeId.equals(that.privilegeId) : that.privilegeId != null) return false;
  83. if (username != null ? !username.equals(that.username) : that.username != null) return false;
  84. if (password != null ? !password.equals(that.password) : that.password != null) return false;
  85. if (email != null ? !email.equals(that.email) : that.email != null) return false;
  86.  
  87. return true;
  88. }
  89.  
  90. @Override
  91. public int hashCode() {
  92. int result = userId;
  93. result = 31 * result + (privilegeId != null ? privilegeId.hashCode() : 0);
  94. result = 31 * result + (username != null ? username.hashCode() : 0);
  95. result = 31 * result + (password != null ? password.hashCode() : 0);
  96. result = 31 * result + (email != null ? email.hashCode() : 0);
  97. return result;
  98. }
  99.  
  100. @Override
  101. public String toString() {
  102. return "UserDataEntity{" +
  103. "userId=" + userId +
  104. ", privilegeId=" + privilegeId +
  105. ", username='" + username + '\'' +
  106. ", password='" + password + '\'' +
  107. ", email='" + email + '\'' +
  108. ", privilegeByPrivilegeId=" + privilegeByPrivilegeId +
  109. '}';
  110. }
  111.  
  112. @ManyToOne
  113. @JoinColumn(name = "privilegeId", referencedColumnName = "privilegeId", insertable = false, updatable = false)
  114. public PrivilegeEntity getPrivilegeByPrivilegeId() {
  115. return privilegeByPrivilegeId;
  116. }
  117.  
  118. public void setPrivilegeByPrivilegeId(PrivilegeEntity privilegeByPrivilegeId) {
  119. this.privilegeByPrivilegeId = privilegeByPrivilegeId;
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement