From cac880df01c7b9b5fe623fae6180849df7858026 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 14 Apr 2022 22:26:12 +0200 Subject: [PATCH] Modifiy table users --- .../java/com/covas/ApplicationLifeCycle.java | 8 ++++++-- src/main/java/com/covas/Users.java | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/covas/ApplicationLifeCycle.java b/src/main/java/com/covas/ApplicationLifeCycle.java index 1c6edea..ac04296 100644 --- a/src/main/java/com/covas/ApplicationLifeCycle.java +++ b/src/main/java/com/covas/ApplicationLifeCycle.java @@ -30,10 +30,14 @@ public class ApplicationLifeCycle { LOGGER.info("The application has started"); if (schemaCreate){ Users users = new Users(); - if(users.findByName("Peter") == null){ - users.name = "Peter"; + if(users.findByPseudo("Peter") == null){ + users.pseudo = "Peter"; + users.email = "peter@email.com"; + users.name = "Toto"; + users.firstName = "Peter"; users.birth = LocalDate.of(1993, Month.FEBRUARY, 23); users.status = true; + users.password = "toto"; users.persist(); LOGGER.info("Users test was created"); } else { diff --git a/src/main/java/com/covas/Users.java b/src/main/java/com/covas/Users.java index d6fcee2..14f413e 100644 --- a/src/main/java/com/covas/Users.java +++ b/src/main/java/com/covas/Users.java @@ -2,19 +2,34 @@ package com.covas; import java.time.LocalDate; +import javax.persistence.Column; import javax.persistence.Entity; +import org.hibernate.annotations.ColumnDefault; + import io.quarkus.hibernate.orm.panache.PanacheEntity; @Entity public class Users extends PanacheEntity { + + @Column(nullable = false, unique = true) + public String pseudo; + @Column(nullable = false, unique = true) + public String email; + @Column(nullable = false) public String name; + @Column(nullable = false) + public String firstName; + @Column(nullable = false) public LocalDate birth; + @ColumnDefault("false") public Boolean status; + @Column(nullable = false) + public String password; - public static Users findByName(String name){ - return find("name", name).firstResult(); + public static Users findByPseudo(String pseudo){ + return find("pseudo", pseudo).firstResult(); } }