Exemple #1
0
 public boolean equals(Object o) {
   if (o == null) return false;
   if (!(o instanceof Person4)) return false;
   Person4 p0 = (Person4) o;
   PersonId4 id0 = p0.getId();
   if (!id.equals(id0)) return false;
   MedicalHistory4 medical0 = p0.getMedical();
   if (medical != null && !medical.patient.getId().equals(medical0.patient.getId())) return false;
   if (medical == null && medical0 != null) return false;
   return true;
 }
 public Person4 createPerson4(EntityManager em, int id) {
   Person4 p = new Person4();
   p.setId(new PersonId4("f_" + id, "l_" + id));
   MedicalHistory4 m = createMedicalHistory4(em, mId4++);
   m.setPatient(p);
   p.setMedical(m);
   em.persist(p);
   em.persist(m);
   persons4.put(p.getId().getFirstName(), p);
   medicals4.put(m.getPatient().getId().getFirstName(), m);
   return p;
 }
  public void findObj7() {
    EntityManager em = emf.createEntityManager();
    Person4 p = em.find(Person4.class, new PersonId4("f_1", "l_1"));
    Person4 p0 = persons4.get("f_1");
    Person4 p1 = p.getMedical().getPatient();
    assertEquals(p1, p);
    em.clear();

    MedicalHistory4 m = em.find(MedicalHistory4.class, new PersonId4("f_1", "l_1"));
    MedicalHistory4 m0 = medicals4.get("f_1");
    assertEquals(m, m0);
    em.close();
  }