commit inicial
This commit is contained in:
commit
25e4f2f6e2
41
.classpath
Normal file
41
.classpath
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-25">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
||||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/bin/
|
||||||
|
*.class
|
||||||
|
/target/
|
||||||
23
.project
Normal file
23
.project
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>aadd_act3_3</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
||||||
8
.settings/org.eclipse.jdt.core.prefs
Normal file
8
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
||||||
20
pom.xml
Normal file
20
pom.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.lapaloma.aadd</groupId>
|
||||||
|
<artifactId>aadd_act3_3</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<dependencies>
|
||||||
|
<!-- Hibernate Core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.orm</groupId>
|
||||||
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
<version>7.1.11.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- MySQL Connector/J -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>9.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
15
src/main/java/org/lapaloma/aadd/redmetro/AppRedMetro.java
Normal file
15
src/main/java/org/lapaloma/aadd/redmetro/AppRedMetro.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro;
|
||||||
|
|
||||||
|
import org.lapaloma.aadd.redmetro.gestores.GestorSesionesHibernate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clase principal que inicia la sesión de Hibernate.
|
||||||
|
* Al iniciar la sesión, Hibernate ejecutará hbm2ddl.auto=create y recreará la base de datos
|
||||||
|
* según las entidades definidas.
|
||||||
|
*/
|
||||||
|
public class AppRedMetro {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Obtiene la Session de forma estática
|
||||||
|
GestorSesionesHibernate.getSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.gestores;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* GestorSesionesHibernate: Clase que realiza ....
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
* @date 4 dic 2025
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GestorSesionesHibernate {
|
||||||
|
private static SessionFactory sessionFactory = null;
|
||||||
|
|
||||||
|
private GestorSesionesHibernate() {// Constructor privado para evitar instanciación
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga la configuración desde hibernate.cfg.xml
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
sessionFactory = new Configuration().configure().buildSessionFactory();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
System.err.println("Error en SessionFactory: " + ex);
|
||||||
|
throw new ExceptionInInitializerError(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Session getSession() {
|
||||||
|
return sessionFactory.openSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cerrarFactoria() {
|
||||||
|
if (sessionFactory != null) {
|
||||||
|
sessionFactory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
src/main/java/org/lapaloma/aadd/redmetro/vo/Acceso.java
Normal file
63
src/main/java/org/lapaloma/aadd/redmetro/vo/Acceso.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_ACCESO.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_ACCESO")
|
||||||
|
public class Acceso {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "cod_acceso")
|
||||||
|
private int codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "acceso_discapacidad", columnDefinition = "int", nullable = false)
|
||||||
|
private boolean accesoDiscapacidad;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "cod_estacion", nullable = false)
|
||||||
|
private Estacion estacion;
|
||||||
|
|
||||||
|
public int getCodigo() {
|
||||||
|
return codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigo(int codigo) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccesoDiscapacidad() {
|
||||||
|
return accesoDiscapacidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccesoDiscapacidad(boolean accesoDiscapacidad) {
|
||||||
|
this.accesoDiscapacidad = accesoDiscapacidad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Estacion getEstacion() {
|
||||||
|
return estacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstacion(Estacion estacion) {
|
||||||
|
this.estacion = estacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Acceso [codigo=" + codigo + ", nombre=" + nombre + ", accesoDiscapacidad=" + accesoDiscapacidad
|
||||||
|
+ ", estacion=" + estacion + "]\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
65
src/main/java/org/lapaloma/aadd/redmetro/vo/Cochera.java
Normal file
65
src/main/java/org/lapaloma/aadd/redmetro/vo/Cochera.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_COCHERA.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_COCHERA")
|
||||||
|
public class Cochera {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "cod_cochera")
|
||||||
|
private int codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 255)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "direccion", nullable = false, length = 255)
|
||||||
|
private String direccion;
|
||||||
|
|
||||||
|
@Column(name = "deposito", columnDefinition = "int")
|
||||||
|
private boolean deposito; // 1 o 0
|
||||||
|
|
||||||
|
|
||||||
|
public int getCodigo() {
|
||||||
|
return codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigo(int codigo) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDireccion() {
|
||||||
|
return direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDireccion(String direccion) {
|
||||||
|
this.direccion = direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDeposito() {
|
||||||
|
return deposito;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeposito(boolean deposito) {
|
||||||
|
this.deposito = deposito;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Cochera [codigo=" + codigo + ", nombre=" + nombre + ", direccion=" + direccion + ", deposito="
|
||||||
|
+ deposito + "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
51
src/main/java/org/lapaloma/aadd/redmetro/vo/Color.java
Normal file
51
src/main/java/org/lapaloma/aadd/redmetro/vo/Color.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_COLOR.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_COLOR")
|
||||||
|
public class Color {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "cod_color")
|
||||||
|
private int codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "cod_hexadecimal", nullable = false, length = 7)
|
||||||
|
private String codHexadecimal;
|
||||||
|
|
||||||
|
public int getCodigo() {
|
||||||
|
return codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigo(int codigo) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodHexadecimal() {
|
||||||
|
return codHexadecimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodHexadecimal(String codHexadecimal) {
|
||||||
|
this.codHexadecimal = codHexadecimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Color [codigo=" + codigo + ", nombre=" + nombre + ", codHexadecimal=" + codHexadecimal + "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
51
src/main/java/org/lapaloma/aadd/redmetro/vo/Estacion.java
Normal file
51
src/main/java/org/lapaloma/aadd/redmetro/vo/Estacion.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_ESTACION.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_ESTACION")
|
||||||
|
public class Estacion {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "cod_estacion")
|
||||||
|
private int codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "direccion", nullable = false, length = 255)
|
||||||
|
private String direccion;
|
||||||
|
|
||||||
|
public int getCodigo() {
|
||||||
|
return codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigo(int codigo) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDireccion() {
|
||||||
|
return direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDireccion(String direccion) {
|
||||||
|
this.direccion = direccion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Estacion [codigo=" + codigo + ", nombre=" + nombre + ", direccion=" + direccion + "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
89
src/main/java/org/lapaloma/aadd/redmetro/vo/Linea.java
Normal file
89
src/main/java/org/lapaloma/aadd/redmetro/vo/Linea.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_LINEA.
|
||||||
|
* Relación OneToOne con T_COLOR (código único).
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_LINEA")
|
||||||
|
public class Linea {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "cod_linea")
|
||||||
|
private int codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre_corto", nullable = false, length = 50)
|
||||||
|
private String nombreCorto;
|
||||||
|
|
||||||
|
@Column(name = "nombre_largo", nullable = false, length = 100)
|
||||||
|
private String nombreLargo;
|
||||||
|
|
||||||
|
// Relación OneToOne con T_COLOR (clave única)
|
||||||
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "cod_color", nullable = false, unique = true)
|
||||||
|
private Color color;
|
||||||
|
|
||||||
|
@Column(name = "kilometros", nullable = false, precision = 5, scale = 2)
|
||||||
|
private BigDecimal kilometros;
|
||||||
|
|
||||||
|
|
||||||
|
public int getCodigo() {
|
||||||
|
return codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigo(int codigo) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombreCorto() {
|
||||||
|
return nombreCorto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombreCorto(String nombreCorto) {
|
||||||
|
this.nombreCorto = nombreCorto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombreLargo() {
|
||||||
|
return nombreLargo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombreLargo(String nombreLargo) {
|
||||||
|
this.nombreLargo = nombreLargo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getKilometros() {
|
||||||
|
return kilometros;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKilometros(BigDecimal kilometros) {
|
||||||
|
this.kilometros = kilometros;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Linea [codigo=" + codigo + ", nombreCorto=" + nombreCorto + ", nombreLargo=" + nombreLargo + ", color="
|
||||||
|
+ color + ", kilometros=" + kilometros + "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_LINEA_ESTACION. Usa una clave primaria
|
||||||
|
* compuesta mediante @EmbeddedId.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_LINEA_ESTACION")
|
||||||
|
public class LineaEstacion {
|
||||||
|
@EmbeddedId
|
||||||
|
private LineaEstacionId id;
|
||||||
|
|
||||||
|
@Column(name = "orden", nullable = false)
|
||||||
|
private int orden;
|
||||||
|
|
||||||
|
// Relaciones a T_LINEA y T_ESTACION mediante los campos de la clave compuesta
|
||||||
|
@MapsId("codigoLinea")
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "cod_linea", nullable = false)
|
||||||
|
private Linea linea;
|
||||||
|
|
||||||
|
@MapsId("codigoEstacion")
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "cod_estacion", nullable = false)
|
||||||
|
private Estacion estacion;
|
||||||
|
|
||||||
|
public LineaEstacion() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineaEstacion(Linea linea, Estacion estacion, Integer orden) {
|
||||||
|
this.linea = linea;
|
||||||
|
this.estacion = estacion;
|
||||||
|
this.orden = orden;
|
||||||
|
this.id = new LineaEstacionId(linea.getCodigo(), estacion.getCodigo());
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineaEstacionId getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(LineaEstacionId id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrden() {
|
||||||
|
return orden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrden(int orden) {
|
||||||
|
this.orden = orden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Linea getLinea() {
|
||||||
|
return linea;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinea(Linea linea) {
|
||||||
|
this.linea = linea;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Estacion getEstacion() {
|
||||||
|
return estacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstacion(Estacion estacion) {
|
||||||
|
this.estacion = estacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "LineaEstacion [id=" + id + ", orden=" + orden + ", linea=" + linea + ", estacion=" + estacion + "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clase embebible que representa la clave primaria compuesta de
|
||||||
|
* T_LINEA_ESTACION.
|
||||||
|
*/
|
||||||
|
@Embeddable
|
||||||
|
public class LineaEstacionId implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Column(name = "cod_linea")
|
||||||
|
private Integer codigoLinea;
|
||||||
|
|
||||||
|
@Column(name = "cod_estacion")
|
||||||
|
private Integer codigoEstacion;
|
||||||
|
|
||||||
|
public LineaEstacionId() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineaEstacionId(Integer codLinea, Integer codEstacion) {
|
||||||
|
this.codigoLinea = codLinea;
|
||||||
|
this.codigoEstacion = codEstacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
|
||||||
|
LineaEstacionId claveObjetoNuevo = (LineaEstacionId) o;
|
||||||
|
return Objects.equals(codigoLinea, claveObjetoNuevo.codigoLinea) && Objects.equals(codigoEstacion, claveObjetoNuevo.codigoEstacion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(codigoLinea, codigoEstacion);
|
||||||
|
}
|
||||||
|
}
|
||||||
97
src/main/java/org/lapaloma/aadd/redmetro/vo/Tren.java
Normal file
97
src/main/java/org/lapaloma/aadd/redmetro/vo/Tren.java
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package org.lapaloma.aadd.redmetro.vo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_TREN.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_TREN")
|
||||||
|
public class Tren {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "cod_tren")
|
||||||
|
private int codigo;
|
||||||
|
|
||||||
|
@Column(name = "modelo", nullable = false, length = 100)
|
||||||
|
private String modelo;
|
||||||
|
|
||||||
|
@Column(name = "empresa_constructora", nullable = false, length = 255)
|
||||||
|
private String empresaConstructora;
|
||||||
|
|
||||||
|
@Column(name = "fecha_incorporacion")
|
||||||
|
private LocalDate fechaIncorporacion;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "cod_cochera", nullable = false)
|
||||||
|
private Cochera cochera;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "cod_linea", nullable = false)
|
||||||
|
private Linea linea;
|
||||||
|
|
||||||
|
public int getCodigo() {
|
||||||
|
return codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigo(int codigo) {
|
||||||
|
this.codigo = codigo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelo() {
|
||||||
|
return modelo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModelo(String modelo) {
|
||||||
|
this.modelo = modelo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmpresaConstructora() {
|
||||||
|
return empresaConstructora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresaConstructora(String empresaConstructora) {
|
||||||
|
this.empresaConstructora = empresaConstructora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getFechaIncorporacion() {
|
||||||
|
return fechaIncorporacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFechaIncorporacion(LocalDate fechaIncorporacion) {
|
||||||
|
this.fechaIncorporacion = fechaIncorporacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cochera getCochera() {
|
||||||
|
return cochera;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCochera(Cochera cochera) {
|
||||||
|
this.cochera = cochera;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Linea getLinea() {
|
||||||
|
return linea;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinea(Linea linea) {
|
||||||
|
this.linea = linea;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Tren [codigo=" + codigo + ", modelo=" + modelo + ", empresaConstructora=" + empresaConstructora
|
||||||
|
+ ", fechaIncorporacion=" + fechaIncorporacion + ", cochera=" + cochera + ", linea=" + linea + "]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
31
src/main/resources/hibernate.cfg.xml
Normal file
31
src/main/resources/hibernate.cfg.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<!DOCTYPE hibernate-configuration PUBLIC
|
||||||
|
"-//Hibernate/Hibernate Configuration DTD//EN"
|
||||||
|
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||||
|
<hibernate-configuration>
|
||||||
|
<session-factory>
|
||||||
|
<property name="connection.url">jdbc:mysql://192.168.1.36:3306/red_metro</property>
|
||||||
|
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
|
||||||
|
|
||||||
|
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
|
||||||
|
|
||||||
|
<property name="connection.username">root</property>
|
||||||
|
<property name="connection.password">mysql_123</property>
|
||||||
|
|
||||||
|
<!-- DB schema will be updated if needed -->
|
||||||
|
<property name="hbm2ddl.auto">create</property>
|
||||||
|
<property name="show_sql">true</property>
|
||||||
|
<property name="format_sql">true</property>
|
||||||
|
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Cochera"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Color"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Cochera"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Estacion"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Cochera"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Acceso"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Linea"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.Tren"></mapping>
|
||||||
|
<mapping class="org.lapaloma.aadd.redmetro.vo.LineaEstacion"></mapping>
|
||||||
|
|
||||||
|
</session-factory>
|
||||||
|
</hibernate-configuration>
|
||||||
Loading…
Reference in New Issue
Block a user