Bug tonto con hashcode y equals

Decidi quitarlo de los modelos ya que la documentacion de hibernate
informa que no es realmente necesario en este caso de uso

https://docs.jboss.org/hibernate/core/4.0/manual/en-US/html/persistent-classes.html#persistent-classes-equalshashcode
This commit is contained in:
Daniel Cortés
2019-06-18 20:35:50 -04:00
parent dae4ee91cb
commit 02f092fd25
21 changed files with 0 additions and 420 deletions

View File

@@ -3,7 +3,6 @@ package xyz.danielcortes.models;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -127,28 +126,4 @@ public class Arriendo {
public void setEjemplares(List<Ejemplar> ejemplares) {
this.ejemplares = ejemplares;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.costoArriendo, this.fechaArriendo, this.fechaDevolucionEstimada, this.fechaDevolucionReal, this.multa,
this.trabajador, this.Cliente, this.ejemplares);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Arriendo))
return false;
Arriendo arriendo = (Arriendo) o;
return Objects.equals(this.id, arriendo.id) &&
Objects.equals(this.costoArriendo, arriendo.costoArriendo) &&
Objects.equals(this.fechaArriendo, arriendo.fechaArriendo) &&
Objects.equals(this.fechaDevolucionEstimada, arriendo.fechaDevolucionEstimada) &&
Objects.equals(this.fechaDevolucionReal, arriendo.fechaDevolucionReal) &&
Objects.equals(this.multa, arriendo.multa) &&
Objects.equals(this.trabajador, arriendo.trabajador) &&
Objects.equals(this.Cliente, arriendo.Cliente) &&
Objects.equals(this.ejemplares, arriendo.ejemplares);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -75,25 +74,6 @@ public class Autor {
this.libros = libros;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.nombre, this.apellidoPaterno, this.apellidoMaterno, this.libros);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Autor))
return false;
Autor autor = (Autor) o;
return Objects.equals(this.id, autor.id) &&
Objects.equals(this.nombre, autor.nombre) &&
Objects.equals(this.apellidoPaterno, autor.apellidoPaterno) &&
Objects.equals(this.apellidoMaterno, autor.apellidoMaterno) &&
Objects.equals(this.libros, autor.libros);
}
@Override
public String toString() {
return this.nombre + " " + this.apellidoPaterno + " " + this.apellidoMaterno;

View File

@@ -3,7 +3,6 @@ package xyz.danielcortes.models;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -85,24 +84,4 @@ public class Boleta {
public void setVentas(List<Venta> ventas) {
this.ventas = ventas;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.folio, this.precioNeto, this.precioIVA, this.fechaVenta, this.ventas);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Boleta))
return false;
Boleta boleta = (Boleta) o;
return Objects.equals(this.id, boleta.id) &&
Objects.equals(this.folio, boleta.folio) &&
Objects.equals(this.precioNeto, boleta.precioNeto) &&
Objects.equals(this.precioIVA, boleta.precioIVA) &&
Objects.equals(this.fechaVenta, boleta.fechaVenta) &&
Objects.equals(this.ventas, boleta.ventas);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -53,23 +52,6 @@ public class Categoria {
this.libros = libros;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.nombre, this.libros);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Categoria))
return false;
Categoria categoria = (Categoria) o;
return Objects.equals(this.id, categoria.id) &&
Objects.equals(this.nombre, categoria.nombre) &&
Objects.equals(this.libros, categoria.libros);
}
@Override
public String toString() {
return this.nombre;

View File

@@ -3,7 +3,6 @@ package xyz.danielcortes.models;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -136,30 +135,4 @@ public class Cliente {
public void setVentas(List<Venta> ventas) {
this.ventas = ventas;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.rut, this.nombre, this.apellidoPaterno, this.apellidoMaterno, this.fechaNacimiento, this.correos,
this.telefonos,
this.direcciones, this.ventas);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Cliente))
return false;
Cliente cliente = (Cliente) o;
return Objects.equals(this.id, cliente.id) &&
Objects.equals(this.rut, cliente.rut) &&
Objects.equals(this.nombre, cliente.nombre) &&
Objects.equals(this.apellidoPaterno, cliente.apellidoPaterno) &&
Objects.equals(this.apellidoMaterno, cliente.apellidoMaterno) &&
Objects.equals(this.fechaNacimiento, cliente.fechaNacimiento) &&
Objects.equals(this.correos, cliente.correos) &&
Objects.equals(this.telefonos, cliente.telefonos) &&
Objects.equals(this.direcciones, cliente.direcciones) &&
Objects.equals(this.ventas, cliente.ventas);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -71,22 +70,4 @@ public class Compra {
public void setEjemplares(List<Ejemplar> ejemplares) {
this.ejemplares = ejemplares;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.factura, this.distribuidor, this.ejemplares);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Compra))
return false;
Compra compra = (Compra) o;
return Objects.equals(this.id, compra.id) &&
Objects.equals(this.factura, compra.factura) &&
Objects.equals(this.distribuidor, compra.distribuidor) &&
Objects.equals(this.ejemplares, compra.ejemplares);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -95,23 +94,4 @@ public class Correo {
public void setClientes(List<Cliente> clientes) {
this.clientes = clientes;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.correo, this.trabajadores, this.distribuidores, this.clientes);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Correo))
return false;
Correo correo1 = (Correo) o;
return Objects.equals(this.id, correo1.id) &&
Objects.equals(this.correo, correo1.correo) &&
Objects.equals(this.trabajadores, correo1.trabajadores) &&
Objects.equals(this.distribuidores, correo1.distribuidores) &&
Objects.equals(this.clientes, correo1.clientes);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -107,23 +106,4 @@ public class Direccion {
this.clientes = clientes;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.calle, this.numero, this.trabajadores, this.distribuidores, this.clientes);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Direccion))
return false;
Direccion direccion = (Direccion) o;
return Objects.equals(this.id, direccion.id) &&
Objects.equals(this.calle, direccion.calle) &&
Objects.equals(this.numero, direccion.numero) &&
Objects.equals(this.trabajadores, direccion.trabajadores) &&
Objects.equals(this.distribuidores, direccion.distribuidores) &&
Objects.equals(this.clientes, direccion.clientes);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -106,24 +105,4 @@ public class Distribuidor {
this.compras = compras;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.rut, this.empresa, this.correos, this.telefonos, this.direcciones, this.compras);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Distribuidor))
return false;
Distribuidor that = (Distribuidor) o;
return Objects.equals(this.id, that.id) &&
Objects.equals(this.rut, that.rut) &&
Objects.equals(this.empresa, that.empresa) &&
Objects.equals(this.correos, that.correos) &&
Objects.equals(this.telefonos, that.telefonos) &&
Objects.equals(this.direcciones, that.direcciones) &&
Objects.equals(this.compras, that.compras);
}
}

View File

@@ -1,7 +1,6 @@
package xyz.danielcortes.models;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -53,23 +52,6 @@ public class Editorial {
this.libros = libros;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.nombre, this.libros);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Editorial))
return false;
Editorial editorial = (Editorial) o;
return Objects.equals(this.id, editorial.id) &&
Objects.equals(this.nombre, editorial.nombre) &&
Objects.equals(this.libros, editorial.libros);
}
@Override
public String toString() {
return this.nombre;

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -105,27 +104,6 @@ public class Ejemplar {
this.ventas = ventas;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.serie, this.libro, this.estado, this.arriendos, this.compras, this.ventas);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Ejemplar))
return false;
Ejemplar ejemplar = (Ejemplar) o;
return Objects.equals(this.id, ejemplar.id) &&
Objects.equals(this.serie, ejemplar.serie) &&
Objects.equals(this.libro, ejemplar.libro) &&
Objects.equals(this.estado, ejemplar.estado) &&
Objects.equals(this.arriendos, ejemplar.arriendos) &&
Objects.equals(this.compras, ejemplar.compras) &&
Objects.equals(this.ventas, ejemplar.ventas);
}
@Override
public String toString() {
return this.serie + " " + this.estado.getNombre();

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -53,23 +52,6 @@ public class Empresa {
this.distribuidores = distribuidores;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.nombre, this.distribuidores);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Empresa))
return false;
Empresa empresa = (Empresa) o;
return Objects.equals(this.id, empresa.id) &&
Objects.equals(this.nombre, empresa.nombre) &&
Objects.equals(this.distribuidores, empresa.distribuidores);
}
@Override
public String toString() {
return this.nombre;

View File

@@ -1,7 +1,6 @@
package xyz.danielcortes.models;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -53,23 +52,6 @@ public class Estado {
this.ejemplares = ejemplares;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.nombre, this.ejemplares);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Estado))
return false;
Estado estado = (Estado) o;
return Objects.equals(this.id, estado.id) &&
Objects.equals(this.nombre, estado.nombre) &&
Objects.equals(this.ejemplares, estado.ejemplares);
}
@Override
public String toString() {
return this.nombre;

View File

@@ -3,7 +3,6 @@ package xyz.danielcortes.models;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -86,23 +85,4 @@ public class Factura {
this.compras = compras;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.folio, this.precioNeto, this.precioIVA, this.fechaVenta, this.compras);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Factura))
return false;
Factura factura = (Factura) o;
return Objects.equals(this.id, factura.id) &&
Objects.equals(this.folio, factura.folio) &&
Objects.equals(this.precioNeto, factura.precioNeto) &&
Objects.equals(this.precioIVA, factura.precioIVA) &&
Objects.equals(this.fechaVenta, factura.fechaVenta) &&
Objects.equals(this.compras, factura.compras);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -53,23 +52,6 @@ public class Idioma {
this.libros = libros;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.nombre, this.libros);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Idioma))
return false;
Idioma idioma = (Idioma) o;
return Objects.equals(this.id, idioma.id) &&
Objects.equals(this.nombre, idioma.nombre) &&
Objects.equals(this.libros, idioma.libros);
}
@Override
public String toString() {
return this.nombre;

View File

@@ -3,7 +3,6 @@ package xyz.danielcortes.models;
import java.time.Year;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
@@ -171,31 +170,6 @@ public class Libro {
this.ejemplares = ejemplar;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.isbn, this.titulo, this.numeroPaginas, this.precioReferencia, this.anoPublicacion, this.idiomas, this.autores,
this.categorias, this.editorial, this.ejemplares);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Libro))
return false;
Libro libro = (Libro) o;
return this.numeroPaginas == libro.numeroPaginas &&
this.precioReferencia == libro.precioReferencia &&
Objects.equals(this.id, libro.id) &&
Objects.equals(this.isbn, libro.isbn) &&
Objects.equals(this.titulo, libro.titulo) &&
Objects.equals(this.anoPublicacion, libro.anoPublicacion) &&
Objects.equals(this.idiomas, libro.idiomas) &&
Objects.equals(this.autores, libro.autores) &&
Objects.equals(this.categorias, libro.categorias) &&
Objects.equals(this.editorial, libro.editorial) &&
Objects.equals(this.ejemplares, libro.ejemplares);
}
@Override
public String toString() {

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -96,22 +95,4 @@ public class Telefono {
this.clientes = clientes;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.numero, this.trabajadores, this.distribuidores, this.clientes);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Telefono))
return false;
Telefono telefono = (Telefono) o;
return Objects.equals(this.id, telefono.id) &&
Objects.equals(this.numero, telefono.numero) &&
Objects.equals(this.trabajadores, telefono.trabajadores) &&
Objects.equals(this.distribuidores, telefono.distribuidores) &&
Objects.equals(this.clientes, telefono.clientes);
}
}

View File

@@ -3,7 +3,6 @@ package xyz.danielcortes.models;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -161,32 +160,5 @@ public class Trabajador {
this.arriendos = arriendos;
}
@Override
public int hashCode() {
return Objects
.hash(this.id, this.rut, this.nombre, this.apellidoPaterno, this.apellidoMaterno, this.fechaContrato, this.usuario, this.correos,
this.telefonos, this.direcciones, this.ventas, this.arriendos);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Trabajador))
return false;
Trabajador that = (Trabajador) o;
return Objects.equals(this.id, that.id) &&
Objects.equals(this.rut, that.rut) &&
Objects.equals(this.nombre, that.nombre) &&
Objects.equals(this.apellidoPaterno, that.apellidoPaterno) &&
Objects.equals(this.apellidoMaterno, that.apellidoMaterno) &&
Objects.equals(this.fechaContrato, that.fechaContrato) &&
Objects.equals(this.usuario, that.usuario) &&
Objects.equals(this.correos, that.correos) &&
Objects.equals(this.telefonos, that.telefonos) &&
Objects.equals(this.direcciones, that.direcciones) &&
Objects.equals(this.ventas, that.ventas) &&
Objects.equals(this.arriendos, that.arriendos);
}
}

View File

@@ -1,7 +1,5 @@
package xyz.danielcortes.models;
import java.util.Arrays;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -72,25 +70,4 @@ public class Usuario {
this.trabajador = trabajador;
}
@Override
public int hashCode() {
int result = Objects.hash(this.id, this.nombre, this.trabajador);
result = 31 * result + Arrays.hashCode(this.password);
result = 31 * result + Arrays.hashCode(this.salt);
return result;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Usuario))
return false;
Usuario usuario = (Usuario) o;
return Objects.equals(this.id, usuario.id) &&
Objects.equals(this.nombre, usuario.nombre) &&
Arrays.equals(this.password, usuario.password) &&
Arrays.equals(this.salt, usuario.salt) &&
Objects.equals(this.trabajador, usuario.trabajador);
}
}

View File

@@ -2,7 +2,6 @@ package xyz.danielcortes.models;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -84,22 +83,4 @@ public class Venta {
this.ejemplares = ejemplares;
}
@Override
public int hashCode() {
return Objects.hash(this.id, this.cliente, this.trabajador, this.boleta, this.ejemplares);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Venta))
return false;
Venta venta = (Venta) o;
return Objects.equals(this.id, venta.id) &&
Objects.equals(this.cliente, venta.cliente) &&
Objects.equals(this.trabajador, venta.trabajador) &&
Objects.equals(this.boleta, venta.boleta) &&
Objects.equals(this.ejemplares, venta.ejemplares);
}
}