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

    birthRecords.addAll((Collection<? extends Birth>) q.getResultList());

    List<Event> childrenBirths = new ArrayList<Event>();
    for (Birth b : birthRecords) {
      if (b != null) {
        ChildRecord cr = new ChildRecord();
        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());
        childrenBirths.add(cr);
      }
    }
    em.getTransaction().commit();
    return childrenBirths;
  }
コード例 #2
0
 @Override
 public void updateBirth(Birth b) {
   em.getTransaction().begin();
   Birth target = em.find(Birth.class, b.getId());
   target.setCountry(b.getCountry());
   target.setEventDate(b.getEventDate());
   target.setPerson(b.getPerson());
   target.setState_province(b.getState_province());
   target.setTown(b.getTown());
   target.setParents(b.getParents());
   em.merge(target);
   em.getTransaction().commit();
 }