Exemple #1
0
  public static Customer convertEntityToCustomer(carrental.model.jpa.entities.Customer entity) {
    Customer customer = new Customer();

    customer.setId(entity.getId());
    customer.setFirstName(entity.getFirstName());
    customer.setLastName(entity.getLastName());
    customer.setIdCode(entity.getIdCode());

    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(entity.getRegisterDate());

    customer.setRegisterDate(calendar);

    return customer;
  }
Exemple #2
0
  public static carrental.model.jpa.entities.Customer convertCustomerToEntity(
      Customer customer, EntityManager manager) {
    carrental.model.jpa.entities.Customer entity = new carrental.model.jpa.entities.Customer();

    entity.setId(customer.getId());
    entity.setFirstName(customer.getFirstName());
    entity.setLastName(customer.getLastName());
    entity.setIdCode(customer.getIdCode());
    entity.setRegisterDate(customer.getRegisterDate().getTime());

    if (manager != null) manager.merge(entity);

    return entity;
  }