Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. package com.bookingTransport.model;
  2.  
  3. import javax.persistence.Transient;
  4.  
  5. import javax.persistence.Basic;
  6. import javax.persistence.Column;
  7. import javax.persistence.DiscriminatorColumn;
  8. import javax.persistence.DiscriminatorValue;
  9. import javax.persistence.Entity;
  10. import javax.persistence.GeneratedValue;
  11. import javax.persistence.GenerationType;
  12. import javax.persistence.Id;
  13. import javax.persistence.Inheritance;
  14. import javax.persistence.NamedQuery;
  15. import javax.persistence.DiscriminatorType;
  16. import javax.persistence.InheritanceType;
  17.  
  18. @Entity
  19. @NamedQuery(name = "findUserByEmail", query = "SELECT u FROM User u WHERE u.email = :email")
  20. @DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "DTYPE")
  21. @Inheritance(strategy = InheritanceType.JOINED)
  22. @DiscriminatorValue("GlobalUser")
  23. public class User {
  24. public User() {
  25. super();
  26. }
  27. @Id
  28. @GeneratedValue(strategy = GenerationType.IDENTITY)
  29. private long id;
  30. private String password;
  31. private String phoneNumber;
  32. private String email;
  33. private String city;
  34. private String description;
  35.  
  36. private Byte status;
  37.  
  38. public User(String password, String phoneNumber, String email, String city, String description,
  39. Byte status) {
  40. super();
  41.  
  42. this.password = password;
  43. this.phoneNumber = phoneNumber;
  44. this.email = email;
  45. this.city = city;
  46. this.description = description;
  47.  
  48. this.status = status;
  49. }
  50.  
  51.  
  52. public long getId() {
  53. return id;
  54. }
  55.  
  56. public void setId(long id) {
  57. this.id = id;
  58. }
  59.  
  60.  
  61. public String getPassword() {
  62. return password;
  63. }
  64.  
  65. public void setPassword(String password) {
  66. this.password = password;
  67. }
  68.  
  69.  
  70. public String getEmail() {
  71. return email;
  72. }
  73.  
  74. public void setEmail(String email) {
  75. this.email = email;
  76. }
  77.  
  78. public Byte getStatus() {
  79. return status;
  80. }
  81.  
  82. public void setStatus(Byte status) {
  83. this.status = status;
  84. }
  85.  
  86.  
  87. public String getPhoneNumber() {
  88. return phoneNumber;
  89. }
  90.  
  91. public void setPhoneNumber(String phoneNumber) {
  92. this.phoneNumber = phoneNumber;
  93. }
  94.  
  95.  
  96. public String getCity() {
  97. return city;
  98. }
  99.  
  100. public void setCity(String city) {
  101. this.city = city;
  102. }
  103.  
  104.  
  105. public String getDescription() {
  106. return description;
  107. }
  108.  
  109. public void setDescription(String description) {
  110. this.description = description;
  111. }
  112.  
  113.  
  114.  
  115.  
  116. @Override
  117. public int hashCode() {
  118. final int prime = 31;
  119. int result = 1;
  120. result = prime * result + ((city == null) ? 0 : city.hashCode());
  121. result = prime * result + ((description == null) ? 0 : description.hashCode());
  122. result = prime * result + ((email == null) ? 0 : email.hashCode());
  123. result = prime * result + (int) (id ^ (id >>> 32));
  124. result = prime * result + ((password == null) ? 0 : password.hashCode());
  125. result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
  126. result = prime * result + ((status == null) ? 0 : status.hashCode());
  127. return result;
  128. }
  129.  
  130.  
  131. @Override
  132. public String toString() {
  133. return "User [id=" + id + ", password=" + password + ", phoneNumber=" + phoneNumber + ", email=" + email
  134. + ", city=" + city + ", description=" + description + ", status=" + status + "]";
  135. }
  136.  
  137. @Transient
  138. public String getDiscriminatorValue() {
  139. System.out.println("User type is: " + this.getClass().getAnnotation(DiscriminatorValue.class).value());
  140. return this.getClass().getAnnotation(DiscriminatorValue.class).value();
  141. }
  142.  
  143.  
  144. @Override
  145. public boolean equals(Object obj) {
  146. if (this == obj)
  147. return true;
  148. if (obj == null)
  149. return false;
  150. if (getClass() != obj.getClass())
  151. return false;
  152. User other = (User) obj;
  153. if (city == null) {
  154. if (other.city != null)
  155. return false;
  156. } else if (!city.equals(other.city))
  157. return false;
  158. if (description == null) {
  159. if (other.description != null)
  160. return false;
  161. } else if (!description.equals(other.description))
  162. return false;
  163. if (email == null) {
  164. if (other.email != null)
  165. return false;
  166. } else if (!email.equals(other.email))
  167. return false;
  168. if (id != other.id)
  169. return false;
  170. if (password == null) {
  171. if (other.password != null)
  172. return false;
  173. } else if (!password.equals(other.password))
  174. return false;
  175. if (phoneNumber == null) {
  176. if (other.phoneNumber != null)
  177. return false;
  178. } else if (!phoneNumber.equals(other.phoneNumber))
  179. return false;
  180. if (status == null) {
  181. if (other.status != null)
  182. return false;
  183. } else if (!status.equals(other.status))
  184. return false;
  185. return true;
  186. }
  187.  
  188.  
  189.  
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement