Editable table and BeanItemContainer

Hi,
I don’t know, how to propagate changes from editable table to database - where to place the code for persisting all changed rows from the table, neither how to recognize which rows was changed.
Thanks for Your help.

@SpringView(name = "clientList")
public class ClientList extends VerticalLayout implements View {

  @Autowired
  private ClientDAO clientDao;
  private Table table;
  private BeanItemContainer<Client> data;

  @PostConstruct
  public void init() {
    data = new BeanItemContainer(Client.class);
    data.addAll(clientDao.findAll());

    table = new Table();
    table.setContainerDataSource(data);
    table.setEditable(false);
    table.setImmediate(true);

    bEditSave = new Button("Edit");
    bEditSave.addClickListener(new Button.ClickListener() {
      @Override
      public void buttonClick(Button.ClickEvent event) {
        if (table.isEditable()) {
          //save
          bEditSave.setCaption("Edit");
          table.commit();
        } else {
          bEditSave.setCaption("Save");
        }
        table.setEditable(!table.isEditable());
      }
    });

    addComponent(table);
  }

}