private void update(Employee employee) {
    String query = "update Employee set name=?, role=? where id=?";
    log.info("Executing query :: " + query);
    Object[] args = new Object[] {employee.getName(), employee.getRole(), employee.getId()};

    int out = jdbcTemplate.update(query, args);
    if (out != 0) {
      log.info("Employee updated with id=" + employee.getId());
    } else log.info("No Employee found with id=" + employee.getId());
  }
  private void save(Employee employee) {

    String query = "insert into Employee (name, role) values (?,?)";
    log.info("Executing query :: " + query);
    Object[] args = new Object[] {employee.getName(), employee.getRole()};

    int out = jdbcTemplate.update(query, args);

    if (out != 0) {
      log.info("Employee saved with id=" + employee.getId());
    } else log.info("Employee save failed with id=" + employee.getId());
  }
  // For add and update person both
  @RequestMapping(value = "/employee/add", method = RequestMethod.POST)
  public String addPerson(@ModelAttribute("employee") Employee p) {

    if (p.getId() == 0) {
      // new person, add it
      save(p);
    } else {
      // existing person, call update
      update(p);
    }

    return "redirect:/home";
  }