its-Quasi /
learn-hexagonal-spring
Primeros pasos usando una arquitectura hexagonal usando java y spring
Active repository
JavaNo license
⑂ 0 forks◯ 0 issuesUpdated Apr 14, 2023
Loading repository data…
AlfreGood20 / repository
Primeros paso usando JPA e hibernate con MySQL un ejemplo de la vida real como ejemplo una escuela, igualmente use libreria como lombok para que sea el desarrollo mas rapido.
| Acción | Método JPA | Ejemplo |
|---|---|---|
| Agregar | em.persist(objeto) | em.persist(alumno); |
| Consultar | em.find(Clase.class, id) | em.find(Alumno.class, 1L); |
| Actualizar | em.merge(objeto) | em.merge(alumno); |
| Eliminar | em.remove(objeto) | em.remove(alumno); |
import jakarta.persistence.*;
public class Main {
public static void main(String[] args) {
try (EntityManagerFactory emf = Persistence.createEntityManagerFactory("my persis")) { //AQUI DEBES DE PONER EL NOMBRE LA PERSISTENCIA
//LLAMAS EL MANAGER PARA EMPEZAR HACER TRANSACIONES
try (EntityManager em = emf.createEntityManager()) {
em.getTransaction().begin(); //INICIAR TRANSACION
em.getTransaction().commit(); //FINALIZAR TRANSACION
}
} catch (Exception e) {
System.out.println(e.getMessage()); //MENSAJE DE ERROR PARA SABER QUE TIPO DE ERROR HAY
}
}
}
Selected from shared topics, language and repository description—not editorial ratings.
its-Quasi /
Primeros pasos usando una arquitectura hexagonal usando java y spring