From 03a13c52b26313f46997460b535294c5aa6438e4 Mon Sep 17 00:00:00 2001 From: Amparo Oliver Date: Thu, 17 Aug 2023 10:54:49 -0400 Subject: [PATCH] spring.jpa.hibernate.ddl-auto=update --- curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar | Bin 72932754 -> 0 bytes curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java | 26 +++++++++++++++++--------- curriculumsearch/src/main/resources/application.properties | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar b/curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar index f21053f..9d8204b 100644 Binary files a/curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar and b/curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar differ diff --git a/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java b/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java index 5d665c2..93fd56d 100644 --- a/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java +++ b/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java @@ -43,16 +43,24 @@ public class CurriculumsearchApplication { guardarJson(ciudR,"/json/Ciudad.json",Ciudad.class); guardarJson(tecRepo,"/json/tecnologia.json",Tecnologia.class); guardarJson(insR,"/json/institucion.json",Institucion.class); - guardarJson(postRepo,"/json/postulante.json",Postulante.class); - + //guardarJson(postRepo,"/json/postulante.json",Postulante.class); + String password = new BCryptPasswordEncoder().encode("test"); - RRHHUser testuser = new RRHHUser(); - testuser.setEmail("test@test.com"); - testuser.setFirstName("test"); - testuser.setLastName("test"); - testuser.setPassword(password); - rrhhUserRepository.save(testuser); - System.out.println("Usuario Test: \nEmail: test@test.com\nPassword: test"); + String testEmail = "test@test.com"; + + // Check if the user with the email already exists before saving + RRHHUser existingUser = rrhhUserRepository.findByEmail(testEmail); + if (existingUser == null) { + RRHHUser testuser = new RRHHUser(); + testuser.setEmail(testEmail); + testuser.setFirstName("test"); + testuser.setLastName("test"); + testuser.setPassword(password); + rrhhUserRepository.save(testuser); + System.out.println("Usuario Test: \nEmail: " + testEmail + "\nPassword: test"); + } else { + System.out.println("User with email " + testEmail + " already exists."); + } } catch (IOException e){ System.out.println("Unable to save: " + e.getMessage()); diff --git a/curriculumsearch/src/main/resources/application.properties b/curriculumsearch/src/main/resources/application.properties index f7c64bd..3a5dcc2 100644 --- a/curriculumsearch/src/main/resources/application.properties +++ b/curriculumsearch/src/main/resources/application.properties @@ -1,5 +1,5 @@ -spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.ddl-auto=update spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect #spring.jpa.show-sql=true #spring.jpa.properties.hibernate.format_sql=true -- libgit2 0.26.0