Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package es.unileon.glassfishapp;
- import java.io.Serializable;
- import java.util.Date;
- import java.util.Objects;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.JoinColumn;
- import javax.persistence.ManyToOne;
- import javax.persistence.Table;
- import javax.persistence.Temporal;
- import javax.persistence.TemporalType;
- /**
- *
- * @author Daniel
- */
- @Entity
- @Table(name="usuarios")
- public class Usuario implements Serializable {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
- @Column(name="User")
- private String user;
- @Column(name="Password")
- private String password;
- @Column(name="UltimaConexion")
- @Temporal(TemporalType.TIMESTAMP)
- private Date ultimaConexion;
- @Column(name="Estado")
- private boolean estado;
- @JoinColumn(name="idPersona")
- @ManyToOne
- private Persona persona;
- @JoinColumn(name="idRol")
- @ManyToOne
- private Rol rol;
- public int getId() {
- return id;
- }
- public String getUser() {
- return user;
- }
- public String getPassword() {
- return password;
- }
- public Date getUltimaConexion() {
- return ultimaConexion;
- }
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 79 * hash + this.id;
- hash = 79 * hash + Objects.hashCode(this.user);
- hash = 79 * hash + Objects.hashCode(this.password);
- hash = 79 * hash + Objects.hashCode(this.ultimaConexion);
- hash = 79 * hash + (this.estado ? 1 : 0);
- hash = 79 * hash + Objects.hashCode(this.persona);
- hash = 79 * hash + Objects.hashCode(this.rol);
- return hash;
- }
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Usuario other = (Usuario) obj;
- if (this.id != other.id) {
- return false;
- }
- if (!Objects.equals(this.user, other.user)) {
- return false;
- }
- if (!Objects.equals(this.password, other.password)) {
- return false;
- }
- if (!Objects.equals(this.ultimaConexion, other.ultimaConexion)) {
- return false;
- }
- if (this.estado != other.estado) {
- return false;
- }
- if (!Objects.equals(this.persona, other.persona)) {
- return false;
- }
- if (!Objects.equals(this.rol, other.rol)) {
- return false;
- }
- return true;
- }
- public void setId(int id) {
- this.id = id;
- }
- public void setUser(String user) {
- this.user = user;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public void setUltimaConexion(Date ultimaConexion) {
- this.ultimaConexion = ultimaConexion;
- }
- public void setEstado(boolean estado) {
- this.estado = estado;
- }
- public void setPersona(Persona persona) {
- this.persona = persona;
- }
- public void setRol(Rol rol) {
- this.rol = rol;
- }
- public boolean isEstado() {
- return estado;
- }
- public Persona getPersona() {
- return persona;
- }
- public Rol getRol() {
- return rol;
- }
- // Faltan equals y hashCode
- @Override
- public String toString() {
- return "es.unileon.glassfishapp.Categorie[ id=" + id + " ]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement