Hello!
I have a grid and a SQLCOntainer as datasource for it. I need to enble row editing and saving changes to the database.
I did following steps:
grid.setEditorEnabled(true);
and find on forum those sort of listener:
grid.getEditorFieldGroup().addCommitHandler(new FieldGroup.CommitHandler() {
@Override
public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
//...
}
@Override
public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
//...
try {
dbhelp.container.commit();
//dbhelp.q.beginTransaction();
//dbhelp.q.commit();
} catch (UnsupportedOperationException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
and after i click “save” i got error:
com.vaadin.data.fieldgroup.FieldGroup$CommitException: Commit failed
and
Caused by: com.vaadin.data.util.sqlcontainer.OptimisticLockException: Someone else changed the row that was being updated.
q.setVersionColumn("upd_date");
upd_date is table in PostgreSQL with type timestamp with time zone and defult value set.
I would be much gratefull for the help!