Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package es.unileon.glassfishapp;
  7.  
  8. import java.io.Serializable;
  9. import java.util.Date;
  10. import java.util.Objects;
  11. import javax.persistence.Column;
  12. import javax.persistence.Entity;
  13. import javax.persistence.GeneratedValue;
  14. import javax.persistence.GenerationType;
  15. import javax.persistence.Id;
  16. import javax.persistence.JoinColumn;
  17. import javax.persistence.ManyToOne;
  18. import javax.persistence.Table;
  19. import javax.persistence.Temporal;
  20. import javax.persistence.TemporalType;
  21.  
  22. /**
  23. *
  24. * @author Daniel
  25. */
  26. @Entity
  27. @Table(name="usuarios")
  28. public class Usuario implements Serializable {
  29.  
  30. @Id
  31. @GeneratedValue(strategy = GenerationType.IDENTITY)
  32. private int id;
  33.  
  34. @Column(name="User")
  35. private String user;
  36.  
  37. @Column(name="Password")
  38. private String password;
  39.  
  40. @Column(name="UltimaConexion")
  41. @Temporal(TemporalType.TIMESTAMP)
  42. private Date ultimaConexion;
  43.  
  44. @Column(name="Estado")
  45. private boolean estado;
  46.  
  47. @JoinColumn(name="idPersona")
  48. @ManyToOne
  49. private Persona persona;
  50.  
  51. @JoinColumn(name="idRol")
  52. @ManyToOne
  53. private Rol rol;
  54.  
  55. public int getId() {
  56. return id;
  57. }
  58.  
  59. public String getUser() {
  60. return user;
  61. }
  62.  
  63. public String getPassword() {
  64. return password;
  65. }
  66.  
  67. public Date getUltimaConexion() {
  68. return ultimaConexion;
  69. }
  70.  
  71. @Override
  72. public int hashCode() {
  73. int hash = 3;
  74. hash = 79 * hash + this.id;
  75. hash = 79 * hash + Objects.hashCode(this.user);
  76. hash = 79 * hash + Objects.hashCode(this.password);
  77. hash = 79 * hash + Objects.hashCode(this.ultimaConexion);
  78. hash = 79 * hash + (this.estado ? 1 : 0);
  79. hash = 79 * hash + Objects.hashCode(this.persona);
  80. hash = 79 * hash + Objects.hashCode(this.rol);
  81. return hash;
  82. }
  83.  
  84. @Override
  85. public boolean equals(Object obj) {
  86. if (obj == null) {
  87. return false;
  88. }
  89. if (getClass() != obj.getClass()) {
  90. return false;
  91. }
  92. final Usuario other = (Usuario) obj;
  93. if (this.id != other.id) {
  94. return false;
  95. }
  96. if (!Objects.equals(this.user, other.user)) {
  97. return false;
  98. }
  99. if (!Objects.equals(this.password, other.password)) {
  100. return false;
  101. }
  102. if (!Objects.equals(this.ultimaConexion, other.ultimaConexion)) {
  103. return false;
  104. }
  105. if (this.estado != other.estado) {
  106. return false;
  107. }
  108. if (!Objects.equals(this.persona, other.persona)) {
  109. return false;
  110. }
  111. if (!Objects.equals(this.rol, other.rol)) {
  112. return false;
  113. }
  114. return true;
  115. }
  116.  
  117. public void setId(int id) {
  118. this.id = id;
  119. }
  120.  
  121. public void setUser(String user) {
  122. this.user = user;
  123. }
  124.  
  125. public void setPassword(String password) {
  126. this.password = password;
  127. }
  128.  
  129. public void setUltimaConexion(Date ultimaConexion) {
  130. this.ultimaConexion = ultimaConexion;
  131. }
  132.  
  133. public void setEstado(boolean estado) {
  134. this.estado = estado;
  135. }
  136.  
  137. public void setPersona(Persona persona) {
  138. this.persona = persona;
  139. }
  140.  
  141. public void setRol(Rol rol) {
  142. this.rol = rol;
  143. }
  144.  
  145. public boolean isEstado() {
  146. return estado;
  147. }
  148.  
  149. public Persona getPersona() {
  150. return persona;
  151. }
  152.  
  153. public Rol getRol() {
  154. return rol;
  155. }
  156.  
  157.  
  158.  
  159. // Faltan equals y hashCode
  160.  
  161. @Override
  162. public String toString() {
  163. return "es.unileon.glassfishapp.Categorie[ id=" + id + " ]";
  164. }
  165.  
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement