From 722f7e6d7c8ac2bc83978dd2b0fcf461c7f0424b Mon Sep 17 00:00:00 2001 From: Cristobal Bernal Mayordomo <90463533+Racriberny@users.noreply.github.com> Date: Wed, 14 Dec 2022 18:35:47 +0100 Subject: [PATCH] entidades --- META-INF/persistence.xml | 18 ++++ .../foro/entidades/AutorsEntity.java | 90 ------------------- .../foro/entidades/CategoriaForoEntity.java | 13 --- ...roPrincipalEntity.java => ForoEntity.java} | 49 ++-------- .../foro/entidades/ImagenEntity.java | 51 ----------- .../foro/entidades/RespuestasEntity.java | 43 +++++---- .../entidades/TipoPrivileguiosEntity.java | 51 ----------- .../foro/entidades/UsersEntity.java | 33 +++---- 8 files changed, 68 insertions(+), 280 deletions(-) create mode 100644 META-INF/persistence.xml delete mode 100644 src/main/java/com/cristobalbernal/foro/entidades/AutorsEntity.java rename src/main/java/com/cristobalbernal/foro/entidades/{ForoPrincipalEntity.java => ForoEntity.java} (66%) delete mode 100644 src/main/java/com/cristobalbernal/foro/entidades/ImagenEntity.java delete mode 100644 src/main/java/com/cristobalbernal/foro/entidades/TipoPrivileguiosEntity.java diff --git a/META-INF/persistence.xml b/META-INF/persistence.xml new file mode 100644 index 0000000..2200a54 --- /dev/null +++ b/META-INF/persistence.xml @@ -0,0 +1,18 @@ + + + + + com.cristobalbernal.foro.entidades.CategoriaForoEntity + com.cristobalbernal.foro.entidades.ForoEntity + com.cristobalbernal.foro.entidades.RespuestasEntity + com.cristobalbernal.foro.entidades.UsersEntity + + + + + + + diff --git a/src/main/java/com/cristobalbernal/foro/entidades/AutorsEntity.java b/src/main/java/com/cristobalbernal/foro/entidades/AutorsEntity.java deleted file mode 100644 index b35371a..0000000 --- a/src/main/java/com/cristobalbernal/foro/entidades/AutorsEntity.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.cristobalbernal.foro.entidades; - -import jakarta.persistence.*; - -@Entity -@Table(name = "autors", schema = "foro", catalog = "") -public class AutorsEntity { - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Id - @Column(name = "id", nullable = false) - private int id; - @Basic - @Column(name = "imagen", nullable = true, length = 45) - private String imagen; - @Basic - @Column(name = "name", nullable = true, length = 45) - private String name; - @Basic - @Column(name = "surnames", nullable = true, length = 45) - private String surnames; - @Basic - @Column(name = "email", nullable = true, length = 45) - private String email; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getImagen() { - return imagen; - } - - public void setImagen(String imagen) { - this.imagen = imagen; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getSurnames() { - return surnames; - } - - public void setSurnames(String surnames) { - this.surnames = surnames; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AutorsEntity that = (AutorsEntity) o; - - if (id != that.id) return false; - if (imagen != null ? !imagen.equals(that.imagen) : that.imagen != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (surnames != null ? !surnames.equals(that.surnames) : that.surnames != null) return false; - if (email != null ? !email.equals(that.email) : that.email != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + (imagen != null ? imagen.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (surnames != null ? surnames.hashCode() : 0); - result = 31 * result + (email != null ? email.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/com/cristobalbernal/foro/entidades/CategoriaForoEntity.java b/src/main/java/com/cristobalbernal/foro/entidades/CategoriaForoEntity.java index e3ffd42..de290d1 100644 --- a/src/main/java/com/cristobalbernal/foro/entidades/CategoriaForoEntity.java +++ b/src/main/java/com/cristobalbernal/foro/entidades/CategoriaForoEntity.java @@ -15,9 +15,6 @@ public class CategoriaForoEntity { @Basic @Column(name = "descripcion", nullable = true, length = 45) private String descripcion; - @Basic - @Column(name = "users_id", nullable = false) - private int usersId; public int getId() { return id; @@ -43,14 +40,6 @@ public class CategoriaForoEntity { this.descripcion = descripcion; } - public int getUsersId() { - return usersId; - } - - public void setUsersId(int usersId) { - this.usersId = usersId; - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -59,7 +48,6 @@ public class CategoriaForoEntity { CategoriaForoEntity that = (CategoriaForoEntity) o; if (id != that.id) return false; - if (usersId != that.usersId) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (descripcion != null ? !descripcion.equals(that.descripcion) : that.descripcion != null) return false; @@ -71,7 +59,6 @@ public class CategoriaForoEntity { int result = id; result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (descripcion != null ? descripcion.hashCode() : 0); - result = 31 * result + usersId; return result; } } diff --git a/src/main/java/com/cristobalbernal/foro/entidades/ForoPrincipalEntity.java b/src/main/java/com/cristobalbernal/foro/entidades/ForoEntity.java similarity index 66% rename from src/main/java/com/cristobalbernal/foro/entidades/ForoPrincipalEntity.java rename to src/main/java/com/cristobalbernal/foro/entidades/ForoEntity.java index 1fc17f1..7f6b1f7 100644 --- a/src/main/java/com/cristobalbernal/foro/entidades/ForoPrincipalEntity.java +++ b/src/main/java/com/cristobalbernal/foro/entidades/ForoEntity.java @@ -5,36 +5,27 @@ import jakarta.persistence.*; import java.sql.Timestamp; @Entity -@Table(name = "foro_principal", schema = "foro", catalog = "") -public class ForoPrincipalEntity { +@Table(name = "foro", schema = "foro", catalog = "") +public class ForoEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) @Id @Column(name = "id", nullable = false) private int id; @Basic - @Column(name = "titulo", nullable = true, length = 45) + @Column(name = "titulo", nullable = true, length = 150) private String titulo; @Basic - @Column(name = "descripcion", nullable = true, length = 45) + @Column(name = "descripcion", nullable = true, length = 150) private String descripcion; @Basic @Column(name = "fechaYHora", nullable = true) private Timestamp fechaYHora; @Basic - @Column(name = "autors_id", nullable = false) - private int autorsId; - @Basic @Column(name = "imagen_id", nullable = false) private int imagenId; @Basic - @Column(name = "users_id", nullable = false) - private int usersId; - @Basic @Column(name = "categoria_foro_id", nullable = false) private int categoriaForoId; - @Basic - @Column(name = "Respuestas_id", nullable = false) - private int respuestasId; public int getId() { return id; @@ -68,14 +59,6 @@ public class ForoPrincipalEntity { this.fechaYHora = fechaYHora; } - public int getAutorsId() { - return autorsId; - } - - public void setAutorsId(int autorsId) { - this.autorsId = autorsId; - } - public int getImagenId() { return imagenId; } @@ -84,14 +67,6 @@ public class ForoPrincipalEntity { this.imagenId = imagenId; } - public int getUsersId() { - return usersId; - } - - public void setUsersId(int usersId) { - this.usersId = usersId; - } - public int getCategoriaForoId() { return categoriaForoId; } @@ -100,27 +75,16 @@ public class ForoPrincipalEntity { this.categoriaForoId = categoriaForoId; } - public int getRespuestasId() { - return respuestasId; - } - - public void setRespuestasId(int respuestasId) { - this.respuestasId = respuestasId; - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ForoPrincipalEntity that = (ForoPrincipalEntity) o; + ForoEntity that = (ForoEntity) o; if (id != that.id) return false; - if (autorsId != that.autorsId) return false; if (imagenId != that.imagenId) return false; - if (usersId != that.usersId) return false; if (categoriaForoId != that.categoriaForoId) return false; - if (respuestasId != that.respuestasId) return false; if (titulo != null ? !titulo.equals(that.titulo) : that.titulo != null) return false; if (descripcion != null ? !descripcion.equals(that.descripcion) : that.descripcion != null) return false; if (fechaYHora != null ? !fechaYHora.equals(that.fechaYHora) : that.fechaYHora != null) return false; @@ -134,11 +98,8 @@ public class ForoPrincipalEntity { result = 31 * result + (titulo != null ? titulo.hashCode() : 0); result = 31 * result + (descripcion != null ? descripcion.hashCode() : 0); result = 31 * result + (fechaYHora != null ? fechaYHora.hashCode() : 0); - result = 31 * result + autorsId; result = 31 * result + imagenId; - result = 31 * result + usersId; result = 31 * result + categoriaForoId; - result = 31 * result + respuestasId; return result; } } diff --git a/src/main/java/com/cristobalbernal/foro/entidades/ImagenEntity.java b/src/main/java/com/cristobalbernal/foro/entidades/ImagenEntity.java deleted file mode 100644 index f94bfcd..0000000 --- a/src/main/java/com/cristobalbernal/foro/entidades/ImagenEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.cristobalbernal.foro.entidades; - -import jakarta.persistence.*; - -@Entity -@Table(name = "imagen", schema = "foro", catalog = "") -public class ImagenEntity { - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Id - @Column(name = "id", nullable = false) - private int id; - @Basic - @Column(name = "url", nullable = true, length = 45) - private String url; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ImagenEntity that = (ImagenEntity) o; - - if (id != that.id) return false; - if (url != null ? !url.equals(that.url) : that.url != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + (url != null ? url.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/com/cristobalbernal/foro/entidades/RespuestasEntity.java b/src/main/java/com/cristobalbernal/foro/entidades/RespuestasEntity.java index 744585b..c77f0cc 100644 --- a/src/main/java/com/cristobalbernal/foro/entidades/RespuestasEntity.java +++ b/src/main/java/com/cristobalbernal/foro/entidades/RespuestasEntity.java @@ -15,14 +15,17 @@ public class RespuestasEntity { @Column(name = "Post", nullable = true, length = 45) private String post; @Basic + @Column(name = "fechaYHora", nullable = true) + private Timestamp fechaYHora; + @Basic @Column(name = "Respuestas_id", nullable = false) private int respuestasId; @Basic - @Column(name = "autors_id", nullable = false) - private int autorsId; + @Column(name = "users_id", nullable = false) + private int usersId; @Basic - @Column(name = "fechaYHora", nullable = true) - private Timestamp fechaYHora; + @Column(name = "Foro_id", nullable = false) + private int foroId; public int getId() { return id; @@ -40,6 +43,14 @@ public class RespuestasEntity { this.post = post; } + public Timestamp getFechaYHora() { + return fechaYHora; + } + + public void setFechaYHora(Timestamp fechaYHora) { + this.fechaYHora = fechaYHora; + } + public int getRespuestasId() { return respuestasId; } @@ -48,20 +59,20 @@ public class RespuestasEntity { this.respuestasId = respuestasId; } - public int getAutorsId() { - return autorsId; + public int getUsersId() { + return usersId; } - public void setAutorsId(int autorsId) { - this.autorsId = autorsId; + public void setUsersId(int usersId) { + this.usersId = usersId; } - public Timestamp getFechaYHora() { - return fechaYHora; + public int getForoId() { + return foroId; } - public void setFechaYHora(Timestamp fechaYHora) { - this.fechaYHora = fechaYHora; + public void setForoId(int foroId) { + this.foroId = foroId; } @Override @@ -73,7 +84,8 @@ public class RespuestasEntity { if (id != that.id) return false; if (respuestasId != that.respuestasId) return false; - if (autorsId != that.autorsId) return false; + if (usersId != that.usersId) return false; + if (foroId != that.foroId) return false; if (post != null ? !post.equals(that.post) : that.post != null) return false; if (fechaYHora != null ? !fechaYHora.equals(that.fechaYHora) : that.fechaYHora != null) return false; @@ -84,9 +96,10 @@ public class RespuestasEntity { public int hashCode() { int result = id; result = 31 * result + (post != null ? post.hashCode() : 0); - result = 31 * result + respuestasId; - result = 31 * result + autorsId; result = 31 * result + (fechaYHora != null ? fechaYHora.hashCode() : 0); + result = 31 * result + respuestasId; + result = 31 * result + usersId; + result = 31 * result + foroId; return result; } } diff --git a/src/main/java/com/cristobalbernal/foro/entidades/TipoPrivileguiosEntity.java b/src/main/java/com/cristobalbernal/foro/entidades/TipoPrivileguiosEntity.java deleted file mode 100644 index 2850cc7..0000000 --- a/src/main/java/com/cristobalbernal/foro/entidades/TipoPrivileguiosEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.cristobalbernal.foro.entidades; - -import jakarta.persistence.*; - -@Entity -@Table(name = "tipo_privileguios", schema = "foro", catalog = "") -public class TipoPrivileguiosEntity { - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Id - @Column(name = "id", nullable = false) - private int id; - @Basic - @Column(name = "tipo", nullable = true, length = 45) - private String tipo; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getTipo() { - return tipo; - } - - public void setTipo(String tipo) { - this.tipo = tipo; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TipoPrivileguiosEntity that = (TipoPrivileguiosEntity) o; - - if (id != that.id) return false; - if (tipo != null ? !tipo.equals(that.tipo) : that.tipo != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + (tipo != null ? tipo.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/com/cristobalbernal/foro/entidades/UsersEntity.java b/src/main/java/com/cristobalbernal/foro/entidades/UsersEntity.java index b91655b..48d9fe9 100644 --- a/src/main/java/com/cristobalbernal/foro/entidades/UsersEntity.java +++ b/src/main/java/com/cristobalbernal/foro/entidades/UsersEntity.java @@ -28,11 +28,11 @@ public class UsersEntity { @Column(name = "username", nullable = true, length = 45) private String username; @Basic - @Column(name = "imagen_id", nullable = false) - private int imagenId; + @Column(name = "urlImgen", nullable = true, length = 150) + private String urlImgen; @Basic - @Column(name = "tipo_privileguios_id", nullable = false) - private int tipoPrivileguiosId; + @Column(name = "tipoPrivilegios", nullable = true) + private Byte tipoPrivilegios; public int getId() { return id; @@ -90,20 +90,20 @@ public class UsersEntity { this.username = username; } - public int getImagenId() { - return imagenId; + public String getUrlImgen() { + return urlImgen; } - public void setImagenId(int imagenId) { - this.imagenId = imagenId; + public void setUrlImgen(String urlImgen) { + this.urlImgen = urlImgen; } - public int getTipoPrivileguiosId() { - return tipoPrivileguiosId; + public Byte getTipoPrivilegios() { + return tipoPrivilegios; } - public void setTipoPrivileguiosId(int tipoPrivileguiosId) { - this.tipoPrivileguiosId = tipoPrivileguiosId; + public void setTipoPrivilegios(Byte tipoPrivilegios) { + this.tipoPrivilegios = tipoPrivilegios; } @Override @@ -114,14 +114,15 @@ public class UsersEntity { UsersEntity that = (UsersEntity) o; if (id != that.id) return false; - if (imagenId != that.imagenId) return false; - if (tipoPrivileguiosId != that.tipoPrivileguiosId) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (firstname != null ? !firstname.equals(that.firstname) : that.firstname != null) return false; if (secondname != null ? !secondname.equals(that.secondname) : that.secondname != null) return false; if (password != null ? !password.equals(that.password) : that.password != null) return false; if (email != null ? !email.equals(that.email) : that.email != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; + if (urlImgen != null ? !urlImgen.equals(that.urlImgen) : that.urlImgen != null) return false; + if (tipoPrivilegios != null ? !tipoPrivilegios.equals(that.tipoPrivilegios) : that.tipoPrivilegios != null) + return false; return true; } @@ -135,8 +136,8 @@ public class UsersEntity { result = 31 * result + (password != null ? password.hashCode() : 0); result = 31 * result + (email != null ? email.hashCode() : 0); result = 31 * result + (username != null ? username.hashCode() : 0); - result = 31 * result + imagenId; - result = 31 * result + tipoPrivileguiosId; + result = 31 * result + (urlImgen != null ? urlImgen.hashCode() : 0); + result = 31 * result + (tipoPrivilegios != null ? tipoPrivilegios.hashCode() : 0); return result; } }