Modifiy table users
This commit is contained in:
parent
ca2ae584bc
commit
cac880df01
@ -30,10 +30,14 @@ public class ApplicationLifeCycle {
|
|||||||
LOGGER.info("The application has started");
|
LOGGER.info("The application has started");
|
||||||
if (schemaCreate){
|
if (schemaCreate){
|
||||||
Users users = new Users();
|
Users users = new Users();
|
||||||
if(users.findByName("Peter") == null){
|
if(users.findByPseudo("Peter") == null){
|
||||||
users.name = "Peter";
|
users.pseudo = "Peter";
|
||||||
|
users.email = "peter@email.com";
|
||||||
|
users.name = "Toto";
|
||||||
|
users.firstName = "Peter";
|
||||||
users.birth = LocalDate.of(1993, Month.FEBRUARY, 23);
|
users.birth = LocalDate.of(1993, Month.FEBRUARY, 23);
|
||||||
users.status = true;
|
users.status = true;
|
||||||
|
users.password = "toto";
|
||||||
users.persist();
|
users.persist();
|
||||||
LOGGER.info("Users test was created");
|
LOGGER.info("Users test was created");
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,19 +2,34 @@ package com.covas;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
|
|
||||||
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Users extends PanacheEntity {
|
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;
|
public String name;
|
||||||
|
@Column(nullable = false)
|
||||||
|
public String firstName;
|
||||||
|
@Column(nullable = false)
|
||||||
public LocalDate birth;
|
public LocalDate birth;
|
||||||
|
@ColumnDefault("false")
|
||||||
public Boolean status;
|
public Boolean status;
|
||||||
|
@Column(nullable = false)
|
||||||
|
public String password;
|
||||||
|
|
||||||
public static Users findByName(String name){
|
public static Users findByPseudo(String pseudo){
|
||||||
return find("name", name).firstResult();
|
return find("pseudo", pseudo).firstResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user