CRUD pref resto personne=ok
This commit is contained in:
parent
39c546794c
commit
4dee7c966f
5 changed files with 52 additions and 21 deletions
|
|
@ -4,6 +4,7 @@ package fr.cardon.simpleat.model;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -12,7 +13,9 @@ import javax.persistence.Id;
|
|||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@Entity
|
||||
|
|
@ -24,6 +27,7 @@ public class Personne {
|
|||
private String email;
|
||||
private String password;
|
||||
private Collection<Role> roles = new ArrayList<Role>();
|
||||
private Collection<Preference> preference = new ArrayList<Preference>();
|
||||
|
||||
|
||||
public Personne() {
|
||||
|
|
@ -106,5 +110,17 @@ public class Personne {
|
|||
public void setRoles(Collection<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "preferencePK.personne", cascade = CascadeType.REMOVE)
|
||||
@JsonIgnore
|
||||
public Collection<Preference> getPreference() {
|
||||
return preference;
|
||||
}
|
||||
|
||||
|
||||
public void setPreference(Collection<Preference> preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import javax.persistence.Embeddable;
|
|||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ public class PreferencePK implements Serializable {
|
|||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
||||
@PrimaryKeyJoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||
public Personne getPersonne() {
|
||||
return personne;
|
||||
|
|
@ -50,7 +51,7 @@ public class PreferencePK implements Serializable {
|
|||
|
||||
|
||||
@ManyToOne // TODO mappedBy preferences dans restaurant
|
||||
@JoinColumn(name="id_restau",referencedColumnName ="id_restau" )
|
||||
@PrimaryKeyJoinColumn(name="id_restau",referencedColumnName ="id_restau" )
|
||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||
public Restaurant getRestau() {
|
||||
return restau;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fr.cardon.simpleat.model;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -11,6 +12,7 @@ import javax.persistence.Id;
|
|||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
|
@ -32,7 +34,7 @@ public class Restaurant {
|
|||
private String longitude;
|
||||
private String website;
|
||||
private Collection<TypeRestau> typerestaus = new ArrayList<TypeRestau>();
|
||||
|
||||
private Collection<Preference> preference = new ArrayList<Preference>();
|
||||
//TODO @OneToMany relier avec une collec de preferences
|
||||
|
||||
public Restaurant() {
|
||||
|
|
@ -150,5 +152,17 @@ public class Restaurant {
|
|||
public void setTyperestaus(Collection<TypeRestau> typerestaus) {
|
||||
this.typerestaus = typerestaus;
|
||||
}
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "preferencePK.restau", cascade = CascadeType.REMOVE)
|
||||
@JsonIgnore
|
||||
public Collection<Preference> getPreference() {
|
||||
return preference;
|
||||
}
|
||||
|
||||
|
||||
public void setPreference(Collection<Preference> preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue