Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Grid: how to manage data persistence
Hi,
I want to prompt users for confirmation before persisting edited data to the database. I am using a grid with a beanitemcontainer.
This is my structure:
Person entity class
class Person{
Integer id;
String name;
@OneToMany
Set<Addresses> addresses;
//getters and setters
}
Addresses entity class
class Addresses{
Integer id;
String personAddress;
@ManyToOne
Person person;
BigInteger addressOrder;
Users lastEditedByUser;
BigDecimal someCalculation;
//getters and setters
}
Person View with addresses list ordered by addresses->addressOrder where addressorder is ordered by from the most prefered to the least prefered
class PersonView extends Window{
FormLayout headerLayout; //Populated with components bound from Person bean
Grid addressesGrid;
BeanItemContainer<Addresses> container;
VerticalLayout layout;
public PersonView(Person person){
List<Addresses> addressList=person.getAddresses().stream()
.sorted((a, b)->a.getAddressOrder().compareTo(b.getAddressOrder())
.collect(Collectors.toList());
container=new BeanItemContainer<>(Addresses.class, addressList);
addressesGrid=new Grid("Addresses for Person "+person.getName());
addressesGrid.setEditable(true);
Grid.Column addressOrderCol=addressesGrid.getColumn("addressOrder");
addressOrder.setEditable(true);
//other view configurations
}
}
the problem is whenever a user edits the addressOrder, it is immediately persisted to the database even when the users closes the window without saving. is there a way i can overcome this. Utilizing the commit handler does not make sense as the window is closed without saving (committing) any data (and still any changes are persisted to the db).
​Thanks for your response
Vaadin: 7.6.8
Mysql: 5.1.36
Hibernate 5.2.0
Webserver: jetty 9