Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.bookingTransport.model;
- import javax.persistence.Transient;
- import javax.persistence.Basic;
- import javax.persistence.Column;
- import javax.persistence.DiscriminatorColumn;
- import javax.persistence.DiscriminatorValue;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.Inheritance;
- import javax.persistence.NamedQuery;
- import javax.persistence.DiscriminatorType;
- import javax.persistence.InheritanceType;
- @Entity
- @NamedQuery(name = "findUserByEmail", query = "SELECT u FROM User u WHERE u.email = :email")
- @DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "DTYPE")
- @Inheritance(strategy = InheritanceType.JOINED)
- @DiscriminatorValue("GlobalUser")
- public class User {
- public User() {
- super();
- }
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private long id;
- private String password;
- private String phoneNumber;
- private String email;
- private String city;
- private String description;
- private Byte status;
- public User(String password, String phoneNumber, String email, String city, String description,
- Byte status) {
- super();
- this.password = password;
- this.phoneNumber = phoneNumber;
- this.email = email;
- this.city = city;
- this.description = description;
- this.status = status;
- }
- public long getId() {
- return id;
- }
- public void setId(long id) {
- this.id = id;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public Byte getStatus() {
- return status;
- }
- public void setStatus(Byte status) {
- this.status = status;
- }
- public String getPhoneNumber() {
- return phoneNumber;
- }
- public void setPhoneNumber(String phoneNumber) {
- this.phoneNumber = phoneNumber;
- }
- public String getCity() {
- return city;
- }
- public void setCity(String city) {
- this.city = city;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((city == null) ? 0 : city.hashCode());
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((email == null) ? 0 : email.hashCode());
- result = prime * result + (int) (id ^ (id >>> 32));
- result = prime * result + ((password == null) ? 0 : password.hashCode());
- result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
- result = prime * result + ((status == null) ? 0 : status.hashCode());
- return result;
- }
- @Override
- public String toString() {
- return "User [id=" + id + ", password=" + password + ", phoneNumber=" + phoneNumber + ", email=" + email
- + ", city=" + city + ", description=" + description + ", status=" + status + "]";
- }
- @Transient
- public String getDiscriminatorValue() {
- System.out.println("User type is: " + this.getClass().getAnnotation(DiscriminatorValue.class).value());
- return this.getClass().getAnnotation(DiscriminatorValue.class).value();
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- User other = (User) obj;
- if (city == null) {
- if (other.city != null)
- return false;
- } else if (!city.equals(other.city))
- return false;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (email == null) {
- if (other.email != null)
- return false;
- } else if (!email.equals(other.email))
- return false;
- if (id != other.id)
- return false;
- if (password == null) {
- if (other.password != null)
- return false;
- } else if (!password.equals(other.password))
- return false;
- if (phoneNumber == null) {
- if (other.phoneNumber != null)
- return false;
- } else if (!phoneNumber.equals(other.phoneNumber))
- return false;
- if (status == null) {
- if (other.status != null)
- return false;
- } else if (!status.equals(other.status))
- return false;
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement