If I've, in a single entity A, multiple relations (many to one) towards an entity B (annotated with one to many)? Do I've to put an annotation for each occurrence of A in B?
Example:
Entity A:
@Entity
@Table(name = "patient")
@TableGenerator(name = "tab_gen_pa", initialValue = 30000, allocationSize = 1)
public class Patient implements Serializable, Comparable<Patient> {
@ManyToOne
@Column(name = "birth_region")
private Region birthRegion;
@ManyToOne
@Column(name = "birth_province", length = 2)
private Province birthProvince;
@ManyToOne
@Column(name = "birth_municipality")
private Municipality birthMunicipality;
@Column(name = "living_region")
@ManyToOne
private Region livingRegion;
@Column(name = "living_province", length = 2)
@ManyToOne
private Province livingProvince;
@Column(name = "living_municipality")
@ManyToOne
private Municipality livingMunicipality;
Entity B: Region for example:
@Entity
@Table(name = "region")
@TableGenerator(name = "tab_gen_re", initialValue = 30, allocationSize = 1)
public class Region implements Serializable {
@OneToMany(mappedBy = "livingRegion")
private List<Patient> patients;
Do I've to insert also in Region:
@OneToMany(mappedBy = "birthRegion")
private List<Patient> patientsBirthRegion;
??