SQLContainer & autocommit


Hi Vaadin Forum,

I have a simple issue that is driving me crazy. I have followed all documentation instructions and searched in forums but I am not able to make it works.

I want to add an item to the database. The item is created by using a form. The table (of the database) I am working with has defined NOT NULL constraints for some fields. I set “autocommit” to “false”, since in other case the “sqlContainer.addItem()” method throws an exception warning that NULL values are not allowed by the database in these fields. The point is that by setting “autocommit” to “false” the row is not stored in the database when the “sqlContainer.commit()” is called. I don’t know why.

The point is that if I set “autocommit” to “true” the record is created and updated as expected, but I have to remove all NULL constraints of the database definition, and I doesn’t like it.


I copy the most important parts of the code I am using. While debugging I have checked that all methods are called as expected. Any help is really appreciated. Thanks.

Commit method of the form.

(This is called when the “save” button is pressed)

	public void commit() {
		// Commit the data entered in the form to the actual item.
		// Commit the changes to the database.
		try {
		} catch (RuntimeException ex) {

Commit method of the Container (OperatorDAO).

(This called by the above chunk of code)

public void commit() {
		try {
		} catch (Exception ex) {
			throw new RuntimeException("Changes couldn't be stored.", ex);

Constructor of the Class (OperatorDAO) that contains the container.

	public OperatorDAO() {
		try {
			TableQuery tableQuery = new TableQuery("OPERATOR", DatabaseHelper.getConnection());
			this.container = new SQLContainer(tableQuery);
		} catch (SQLException ex) {
			throw new IllegalStateException("The Operator DAO couldn't be initialized.", ex);

Method used by the container to create the item attached to the form

(In this case, the table is expected to store always just one record)

	public Item getItem() {
		Object itemId = this.container.firstItemId();
		if (itemId == null) {
			itemId = this.container.addItem();
		Item item = this.container.getItem(itemId);
		return item;

For the moment, the solution that I have found is to use the “storeItem” method of the TableQuery class. As far as I can see, this is the mechanism used in the SQLContainer code when the “autocommit” mode is enabled.

	public void storeItem(RowItem newItem) {
		if (newItem == null) {
			throw new IllegalArgumentException("The new item cannot be NULL.");
		try {
		} catch (SQLException e) {
			throw new RuntimeException("Changes in the Opeator data couldn't be done.");

Absolutely the same problem…

I too.
I suspected the filtering, but before adding a new item to the container, I remove all filters.
I check the content of the container before commiting, I have my items with NOT NULL values in my properties.