add onetomany
This commit is contained in:
parent
50db0ab1f2
commit
d42dc014b6
@ -1,5 +1,6 @@
|
||||
package com.covas.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -8,8 +9,8 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.CascadeType;
|
||||
|
||||
|
||||
@ -19,7 +20,7 @@ import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
|
||||
|
||||
@Entity
|
||||
@Table(name = "publisher")
|
||||
public class PublisherEntity extends PanacheEntityBase {
|
||||
public class PublisherEntity extends PanacheEntityBase implements Serializable {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(generator = "UUID")
|
||||
@ -32,7 +33,7 @@ public class PublisherEntity extends PanacheEntityBase {
|
||||
@Column(nullable = false)
|
||||
public LocalDateTime updated_at;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "users_id", referencedColumnName = "id")
|
||||
public UsersEntity users;
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package com.covas.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
@ -10,8 +12,8 @@ import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
import com.covas.Classes.Hash;
|
||||
|
||||
@ -38,7 +40,7 @@ import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
|
||||
@NamedQuery(name = "Users.bySearchandStatus", query = "from UsersEntity u where (u.pseudo like :search or u.name like :search or u.firstName like :search) and u.status = :status"),
|
||||
@NamedQuery(name = "Users.bySearchandRolesandStatus", query = "from UsersEntity u where (u.pseudo like :search or u.name like :search or u.firstName like :search) and u.roles = :roles and u.status = :status")
|
||||
})
|
||||
public class UsersEntity extends PanacheEntityBase {
|
||||
public class UsersEntity extends PanacheEntityBase implements Serializable {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(generator = "UUID")
|
||||
@ -72,8 +74,8 @@ public class UsersEntity extends PanacheEntityBase {
|
||||
|
||||
public String description;
|
||||
|
||||
@OneToOne(mappedBy = "users")
|
||||
public PublisherEntity publisher;
|
||||
@OneToMany(mappedBy = "users")
|
||||
public Collection<PublisherEntity> publisher;
|
||||
|
||||
public static UsersEntity findByPseudo(String pseudo){
|
||||
return find("pseudo", pseudo).firstResult();
|
||||
|
Loading…
x
Reference in New Issue
Block a user