| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 
 | 
@Entity
@Table(name="Patient")
public class Patient implements Serializable{
	
	@Id
	@Column
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int ref;
	//@Column (name="ref", unique=true, nullable=false, length=4, insertable=false, updatable=false)
	private String nom;
	private String prenom;
	private String adresse;
	private int cp;
	private String ville;
	private String telephone;
	private String email;
	private String suivi_par;
	private int type_diabete;
	private String diagnostic;
	
	@OneToMany(mappedBy = "patient", cascade = { CascadeType.ALL })
	@JoinColumn(name="patient_id")
	private List<Mesure> mesures;
	//ou Map ou Set peu importe
	
	
	// constructor from super-class
	public Patient() {
		super();
		this.init();
		// TODO Auto-generated constructor stub
	}
	
	//constructors using fields 
	public Patient(String nom, String prenom, String adresse, int cp,
			String ville, String telephone, String email, String suivi_par,
			int type_diabete, String diagnostic) {
		super();
		this.nom = nom;
		this.prenom = prenom;
		this.adresse = adresse;
		this.cp = cp;
		this.ville = ville;
		this.telephone = telephone;
		this.email = email;
		this.suivi_par = suivi_par;
		this.type_diabete = type_diabete;
		this.diagnostic = diagnostic;
		this.init();
	}
	//getters and setters
	public int getRef() {
		return ref;
	}
	public void setRef(int ref) {
		this.ref = ref;
	}
....
public List<Mesure> getMesures() {
		return mesures;
	}
	public void setMesures(List<Mesure> mesures) {
		this.mesures = mesures;
	}
	
	public void init(){
		mesures= new ArrayList<Mesure>();
	}
	
	public void add(Mesure nouvelle){
		mesures.add(nouvelle);
	} | 
Partager