package entity; import java.io.Serializable; import javax.persistence.*; /** * The persistent class for the users database table. * */ @Entity @Table(name="users") public class User implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(unique=true, nullable=false) private Integer id; private boolean active; @Column(length=64) private String address; @Column(name="cell_phone", length=15) private String cellPhone; @Column(length=32) private String city; @Column(length=512) private String comments; @Column(length=32) private String country; @Column(name="zip_code",length=6) private String zipCode; @Column(length=32) private String email; @Column(length=32) private String name; @Column(length=12) private String nif; @Column(length=32) private String password; @Column(length=15) private String phone; @Column(length=32) private String province; @Column(name="user_name", length=10) private String userName; //bi-directional one-to-one association to Configuration @OneToOne(mappedBy="user", cascade={CascadeType.ALL}) private Configuration configuration; //bi-directional many-to-one association to AccessLevel @ManyToOne @JoinColumn(name="id_access_level") private AccessLevel accessLevel; public User() { } public User(User user) { setUser(user); } public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public boolean isActive() { return this.active; } public void setActive(boolean active) { this.active = active; } public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; } public String getCellPhone() { return this.cellPhone; } public void setCellPhone(String cellPhone) { this.cellPhone = cellPhone; } public String getCity() { return this.city; } public void setCity(String city) { this.city = city; } public String getComments() { return this.comments; } public void setComments(String comments) { this.comments = comments; } public String getCountry() { return this.country; } public void setCountry(String country) { this.country = country; } public String getZipCode() { return this.zipCode; } public void setZipCode(String zipCode) { this.zipCode = zipCode; } public String getEmail() { return this.email; } public void setEmail(String email) { this.email = email; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getNif() { return this.nif; } public void setNif(String nif) { this.nif = nif; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public String getPhone() { return this.phone; } public void setPhone(String phone) { this.phone = phone; } public String getProvince() { return this.province; } public void setProvince(String province) { this.province = province; } public String getUserName() { return this.userName; } public void setUserName(String userName) { this.userName = userName; } public Configuration getConfiguration() { return this.configuration; } public void setConfiguration(Configuration configuration) { this.configuration = configuration; } public AccessLevel getAccessLevel() { return this.accessLevel; } public void setAccessLevel(AccessLevel accessLevel) { this.accessLevel = accessLevel; } public User getUser() { return this; } public void setUser(User user) { setId(user.getId()); setName(user.getName()); setNif(user.getNif()); setAddress(user.getAddress()); setZipCode(user.getZipCode()); setCity(user.getCity()); setProvince(user.getProvince()); setCountry(user.getCountry()); setPhone(user.getPhone()); setCellPhone(user.getCellPhone()); setEmail(user.getEmail()); setUserName(user.getUserName()); setPassword(user.getPassword()); setAccessLevel(user.getAccessLevel()); setActive(user.isActive()); } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof User)) { return false; } User other = (User) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "db.User[id=" + id + "]"; } }