Exemplo n.º 1
0
 /**
  * @param entity
  * @param contacts
  * @param address
  * @return
  */
 public EntityDB SaveContact(EntityDB entity, Collection<ContactDB> contacts, AddressDB address) {
   try {
     // force relation
     entity.setContact(contacts);
     // force relation
     entity.setAddress(address);
     LOG.info("Saving the object Entity on Database");
     entityManager.persist(entity);
     return entity;
   } catch (Exception e) {
     LOG.error("Saving object fail : " + e.getMessage());
     return null;
   }
 }
Exemplo n.º 2
0
  public EntityDB EditContact(EntityDB entity, Collection<ContactDB> contacts, AddressDB address) {
    try {
      EntityDB result = entityManager.find(EntityDB.class, entity.getId_entity());
      result.setLocation(entity.getLocation());
      result.setName(entity.getName());
      result.setPostalCode(entity.getPostalCode());

      // force relation
      entity.setContact(contacts);
      // force relation
      entity.setAddress(address);
      LOG.info("Editting the object Entity on Database");
      entityManager.merge(entity);
      return entity;
    } catch (Exception e) {
      LOG.error("Editting object fail : " + e.getMessage());
      return null;
    }
  }