commit inicial

This commit is contained in:
Isidoro Nevares Martín 2025-12-05 13:38:32 +01:00
commit af43b8cb12
12 changed files with 260 additions and 0 deletions

41
.classpath Normal file
View 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
View File

@ -0,0 +1,3 @@
/bin/
*.class
/target/

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>aadd_act3_1</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>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=24
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=24
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=24

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

23
pom.xml Normal file
View File

@ -0,0 +1,23 @@
<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.mapamundi</groupId>
<artifactId>aadd_act3_1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>7.1.11.Final</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,21 @@
package org.lapaloma.aadd.mapamundi;
import org.lapaloma.aadd.mapamundi.gestores.GestorSesionesHibernate;
/**
*
* AppMapaMundi: Clase que realiza ....
*
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
* @date 5 dic 2025
*
*
*/
public class AppMapaMundi {
public static void main(String[] args) {
GestorSesionesHibernate.getSession();
}
}

View File

@ -0,0 +1,42 @@
package org.lapaloma.aadd.mapamundi.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();
}
}
}

View File

@ -0,0 +1,27 @@
package org.lapaloma.aadd.mapamundi.vo;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
/**
*
* Continente: Clase que se usa para mapear la tabla de continentes
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
* @date 5 dic 2025
*
*
*/
@Entity
@Table(name="T_CONTINENTE")
public class Continente {
@Id
@Column(name="codigo", columnDefinition = "char(2)")
private String codigo;
@Column(name="nombre_continente", length=30, nullable=true)
private String nombreContinente;
}

View File

@ -0,0 +1,36 @@
package org.lapaloma.aadd.mapamundi.vo;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
/**
*
* Continente: Clase que se usa para mapear la tabla de Países
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
* @date 5 dic 2025
*
*
*/
@Entity
@Table(name="T_PAIS")
public class Pais {
@Id
@Column(name="identificador")
private int identificador;
@Column(name="nombre_pais", length=50)
private String nombrePais;
@Column(name="capital", length=20)
private String capital;
@ManyToOne
@JoinColumn(name="cod_continente")
private Continente continente;
}

View File

@ -0,0 +1,25 @@
<?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/Mapa_mundi_aadd</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.mapamundi.vo.Continente"></mapping>
<mapping class="org.lapaloma.aadd.mapamundi.vo.Pais"></mapping>
</session-factory>
</hibernate-configuration>