コード例 #1
0
  @Override
  public List<Event> getChildAdoptionRecords(Person person) {
    // get the birth records of the children of this parent
    List<Adoption> adoptionRecords = new ArrayList<Adoption>();
    em.getTransaction().begin();
    TypedQuery<Adoption> q =
        em.createQuery(
            "select b from Adoption b, IN(b.parents) p WHERE p.id = :idParam", Adoption.class);
    q.setParameter("idParam", person.getId());

    adoptionRecords.addAll(q.getResultList());

    List<Event> adoptions = new ArrayList<Event>();
    for (Adoption b : adoptionRecords) {
      if (b != null) {
        AdoptedChildRecord cr = new AdoptedChildRecord();
        cr.setEventDate(b.getEventDate());
        cr.setPerson(person);
        cr.setChild(b.getPerson());
        cr.setTown(b.getTown());
        cr.setState_province(b.getState_province());
        cr.setCountry(b.getCountry());
        adoptions.add(cr);
      }
    }
    em.getTransaction().commit();
    return adoptions;
  }
コード例 #2
0
 @Override
 public void updateAdoption(Adoption a) {
   em.getTransaction().begin();
   Adoption target = em.find(Adoption.class, a.getId());
   target.setCountry(a.getCountry());
   target.setEventDate(a.getEventDate());
   target.setPerson(a.getPerson());
   target.setState_province(a.getState_province());
   target.setTown(a.getTown());
   target.setParents(a.getParents());
   em.merge(target);
   em.getTransaction().commit();
 }