From f39ed6cb1e40817e2c38951795e07afb0acb5617 Mon Sep 17 00:00:00 2001 From: Juanjo Date: Mon, 30 Jan 2023 17:47:35 +0100 Subject: [PATCH] Importando entidades de la BBDD --- .../fp/edu/conecta2/modelo2/IbexEntity.java | 121 ++++++++++++++++++ .../fp/edu/conecta2/modelo2/Tabla1Entity.java | 63 +++++++++ .../fp/edu/conecta2/modelo2/Tabla2Entity.java | 75 +++++++++++ .../fp/edu/conecta2/modelo2/Tabla3Entity.java | 51 ++++++++ 4 files changed, 310 insertions(+) create mode 100644 src/main/java/es/fp/edu/conecta2/modelo2/IbexEntity.java create mode 100644 src/main/java/es/fp/edu/conecta2/modelo2/Tabla1Entity.java create mode 100644 src/main/java/es/fp/edu/conecta2/modelo2/Tabla2Entity.java create mode 100644 src/main/java/es/fp/edu/conecta2/modelo2/Tabla3Entity.java diff --git a/src/main/java/es/fp/edu/conecta2/modelo2/IbexEntity.java b/src/main/java/es/fp/edu/conecta2/modelo2/IbexEntity.java new file mode 100644 index 0000000..5b9f55e --- /dev/null +++ b/src/main/java/es/fp/edu/conecta2/modelo2/IbexEntity.java @@ -0,0 +1,121 @@ +package es.fp.edu.conecta2.modelo2; + +import jakarta.persistence.Basic; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +import java.math.BigDecimal; +import java.sql.Date; + +@Entity +@Table(name = "ibex", schema = "bolsa", catalog = "") +public class IbexEntity { + @Basic + @Column(name = "date", nullable = false) + private Date date; + @Basic + @Column(name = "open", nullable = false, precision = 6) + private BigDecimal open; + @Basic + @Column(name = "high", nullable = false, precision = 6) + private BigDecimal high; + @Basic + @Column(name = "low", nullable = false, precision = 6) + private BigDecimal low; + @Basic + @Column(name = "close", nullable = false, precision = 6) + private BigDecimal close; + @Basic + @Column(name = "adj_close", nullable = false, precision = 6) + private BigDecimal adjClose; + @Basic + @Column(name = "volume", nullable = false) + private int volume; + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public BigDecimal getOpen() { + return open; + } + + public void setOpen(BigDecimal open) { + this.open = open; + } + + public BigDecimal getHigh() { + return high; + } + + public void setHigh(BigDecimal high) { + this.high = high; + } + + public BigDecimal getLow() { + return low; + } + + public void setLow(BigDecimal low) { + this.low = low; + } + + public BigDecimal getClose() { + return close; + } + + public void setClose(BigDecimal close) { + this.close = close; + } + + public BigDecimal getAdjClose() { + return adjClose; + } + + public void setAdjClose(BigDecimal adjClose) { + this.adjClose = adjClose; + } + + public int getVolume() { + return volume; + } + + public void setVolume(int volume) { + this.volume = volume; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + IbexEntity that = (IbexEntity) o; + + if (volume != that.volume) return false; + if (date != null ? !date.equals(that.date) : that.date != null) return false; + if (open != null ? !open.equals(that.open) : that.open != null) return false; + if (high != null ? !high.equals(that.high) : that.high != null) return false; + if (low != null ? !low.equals(that.low) : that.low != null) return false; + if (close != null ? !close.equals(that.close) : that.close != null) return false; + if (adjClose != null ? !adjClose.equals(that.adjClose) : that.adjClose != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = date != null ? date.hashCode() : 0; + result = 31 * result + (open != null ? open.hashCode() : 0); + result = 31 * result + (high != null ? high.hashCode() : 0); + result = 31 * result + (low != null ? low.hashCode() : 0); + result = 31 * result + (close != null ? close.hashCode() : 0); + result = 31 * result + (adjClose != null ? adjClose.hashCode() : 0); + result = 31 * result + volume; + return result; + } +} diff --git a/src/main/java/es/fp/edu/conecta2/modelo2/Tabla1Entity.java b/src/main/java/es/fp/edu/conecta2/modelo2/Tabla1Entity.java new file mode 100644 index 0000000..e6b1c1a --- /dev/null +++ b/src/main/java/es/fp/edu/conecta2/modelo2/Tabla1Entity.java @@ -0,0 +1,63 @@ +package es.fp.edu.conecta2.modelo2; + +import jakarta.persistence.*; + +import java.util.Collection; + +@Entity +@Table(name = "tabla1", schema = "bolsa", catalog = "") +public class Tabla1Entity { + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Id + @Column(name = "id", nullable = false) + private int id; + @Basic + @Column(name = "nombre", nullable = false, length = 50) + private String nombre; + @OneToMany(mappedBy = "tabla1ByTabla1Id") + private Collection tabla2sById; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Tabla1Entity that = (Tabla1Entity) o; + + if (id != that.id) return false; + if (nombre != null ? !nombre.equals(that.nombre) : that.nombre != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + (nombre != null ? nombre.hashCode() : 0); + return result; + } + + public Collection getTabla2sById() { + return tabla2sById; + } + + public void setTabla2sById(Collection tabla2sById) { + this.tabla2sById = tabla2sById; + } +} diff --git a/src/main/java/es/fp/edu/conecta2/modelo2/Tabla2Entity.java b/src/main/java/es/fp/edu/conecta2/modelo2/Tabla2Entity.java new file mode 100644 index 0000000..e6edec5 --- /dev/null +++ b/src/main/java/es/fp/edu/conecta2/modelo2/Tabla2Entity.java @@ -0,0 +1,75 @@ +package es.fp.edu.conecta2.modelo2; + +import jakarta.persistence.*; + +@Entity +@Table(name = "tabla2", schema = "bolsa", catalog = "") +public class Tabla2Entity { + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Id + @Column(name = "id", nullable = false) + private int id; + @Basic + @Column(name = "nombre", nullable = true, length = 50) + private String nombre; + @Basic + @Column(name = "tabla1_id", nullable = false) + private int tabla1Id; + @ManyToOne + @JoinColumn(name = "tabla1_id", referencedColumnName = "id", nullable = false) + private Tabla1Entity tabla1ByTabla1Id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public int getTabla1Id() { + return tabla1Id; + } + + public void setTabla1Id(int tabla1Id) { + this.tabla1Id = tabla1Id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Tabla2Entity that = (Tabla2Entity) o; + + if (id != that.id) return false; + if (tabla1Id != that.tabla1Id) return false; + if (nombre != null ? !nombre.equals(that.nombre) : that.nombre != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + (nombre != null ? nombre.hashCode() : 0); + result = 31 * result + tabla1Id; + return result; + } + + public Tabla1Entity getTabla1ByTabla1Id() { + return tabla1ByTabla1Id; + } + + public void setTabla1ByTabla1Id(Tabla1Entity tabla1ByTabla1Id) { + this.tabla1ByTabla1Id = tabla1ByTabla1Id; + } +} diff --git a/src/main/java/es/fp/edu/conecta2/modelo2/Tabla3Entity.java b/src/main/java/es/fp/edu/conecta2/modelo2/Tabla3Entity.java new file mode 100644 index 0000000..72a765e --- /dev/null +++ b/src/main/java/es/fp/edu/conecta2/modelo2/Tabla3Entity.java @@ -0,0 +1,51 @@ +package es.fp.edu.conecta2.modelo2; + +import jakarta.persistence.*; + +@Entity +@Table(name = "tabla3", schema = "bolsa", catalog = "") +public class Tabla3Entity { + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Id + @Column(name = "id", nullable = false) + private int id; + @Basic + @Column(name = "nombre", nullable = true, length = 45) + private String nombre; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Tabla3Entity that = (Tabla3Entity) o; + + if (id != that.id) return false; + if (nombre != null ? !nombre.equals(that.nombre) : that.nombre != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + (nombre != null ? nombre.hashCode() : 0); + return result; + } +}