SQLContainer addItem / getProperties

Hey Guys,

i have been trying to add items to my SQLContainer and therefore my Database for several Days now. I have read Every Post in this Forum and on Stackoverflow regarding this Topic that i could find.

Every Time my addButton is clicked, i want to add a new Item to my SQLContainer.
This is an Extract of my Code:

public void buttonClick(ClickEvent event) { try { Object id = eventContainer.addItem(); eventContainer.getContainerProperty(id, "eventId").setValue(0); eventContainer.commit(); } catch (Exception e) { Notification.show("Error adding Item: " + e.getMessage()); } eventContainer.getContainerProperty(id, “eventId”) does fail with a NullPointerException, I just don’t understand why.
I disabled AutoCommit for my Container (which it should be by default), because the addItem() tooltip says that enabled AutoCommit could lead to Troubles and addItem() could return a temporary row id.
When i print the id using id.toString it says “Temporary row id”.
I checked the Containers’ PropertyIds using eventContainer.getContainerPropertyIds() and “eventId” definitely is one of them.
I also tried to use the addItem()-Method using my own id. But addItem(“anyId”) does not seem to work for my Container and returns null

First commiting and then changing the Item-Values is not a possible Solution because my MySQL-Table contains Columns that can not be null.

I am using an IndexedContainer in another class and everything works fine.

I Hope you guys can help me out,
cheers
Patrick

I also have this situation see attach pic

PS https://vaadin.com/forum/#!/thread/9202425 too
18952.jpg

more info https://vaadin.com/forum/#!/thread/1951006

2 years gone
advise what should do


solution
: removed TableQuery.setVersionColumn(id);
because

Note! TableQuery assumes that the database will take care of updating the version column by either using an actual VERSION column (if supported by the database in question) or by a trigger or a similar mechanism.