Remove Item from SQLContainer

Hi !
I’ve faced with the problem of removing items from Table
I use SQLContainer to edit data in Table. The adding is good, but when i’m trying to remove item i get this

I do something like this:

  1. select row from the table
  2. get the id of this row by selectedId = managerTable.getValue();
    3)try to remove it

sqlcontainer.removeItem(selectedId);
sqlcontainer.commit();

and then get that error in commit. Row is removed from the table, but not from DB.

I use vaadin 6.8.4 and postgres
Init of container:

tableQuery = getTableQuery();
tableQuery.setVersionColumn("TLOCK");
sqlcontainer = new SQLContainer(tableQuery);
managerTable.setContainerDataSource(sqlcontainer);

I’ve already read all threads about RemoveItem and haven’t got the clear answer. Has anyone work out this problem? Thanks in advance!

I didn’t have problems with postgre and SQLContainer.

My code is very similar only I didn’t set VersionColumn.

TableQuery tqKontrah = new TableQuery("kontrah", connectionPool);
kontrahContainer = new SQLContainer(tqKontrah);
KontrahTable.setContainerDataSource(kontrahContainer);
	btnRemove.addListener(new Button.ClickListener() {
			
			@Override
			public void buttonClick(ClickEvent event) {
				Object id = KontrahTable.getValue();
				if (id != null) {
					application.getDataSource().getKontrahContainer().removeItem(id);
					try {
						app.getDataSource().getKontrahContainer().commit();
					} catch (UnsupportedOperationException e) {
						e.printStackTrace();
					} catch (SQLException e) {
						e.printStackTrace();
					}
				} 
			}
		});

Are you sure that getValue() gives you proper value?

What returns removeItem method (should be “true”).
If returns “false” then debug SQL removeItem method maybe something is wrong mapped from database.

Anyway debug internal code of SQLContainer by setting brake in removeItem method and in commit will be the best way.
This may be related to the structure of the database.

Thanks for your reply!

This is the key

I remove setVersionColumn from my code and now it’s works!

I knew that the answer is near :slight_smile:
You’ve saved my time, thanks!

I’m glad I could help :smiley: