Saving new rows using SQLContainer and HSQLDB. Trigger?

Hai,

actually I need your help! I am not able to create a new row into my database using SQLContainer and HSQLDB.
I am using Vaadin version 7.1.7.

  1. I create a table with a version column:
    CREATE MEMORY TABLE PICTURE(ID INTEGER GENERATED ALWAYS AS IDENTITY NOT NULL PRIMARY KEY,
    TITLE VARCHAR(64), URL VARCHAR(200), VERSION INTEGER DEFAULT 0)

  2. I create a SQLContainer instance and set the version column:
    TableQuery pictureQuery = new TableQuery(“PICTURE”, pool);
    pictureQuery.setVersionColumn(“VERSION”);
    pictureContainer = new SQLContainer(pictureQuery);

  3. To create a new picture I call the following method:

public void createPicture(Picture picture) throws UnsupportedOperationException, SQLException {

Object id = pictureContainer.addItem();
Item item = pictureContainer.getItem(id);
    
item.getItemProperty("TITLE").setValue(picture.getTitle());
item.getItemProperty("URL").setValue(picture.getUrl());
    
pictureContainer.commit();

}

The picture is not written to the database. Although I am able to update instances that I created manually, I am not able to create new instances.

May this be caused by a missing trigger? Is there any example for a correct HSQLDB trigger definition?
I tried something like the following without success:
CREATE SEQUENCE VSEQ
CREATE TRIGGER VTRIGG BEFORE INSERT ON PUBLIC.PICTURE REFERENCING NEW ROW AS NEWROW FOR EACH ROW SET NEWROW.VERSION = NEXT VALUE FOR VSEQ;

Any help warmly welcome!
Best regards, Wolfgang

Hello,

just FYI, it seems that I found the answer from the following page:


http://stackoverflow.com/questions/7397775/data-is-not-saving-in-memory-table-of-hsql/7422109

I moved my database from inside the WEB-INF folder - where I’d put my database for convenience reasons - to an external folder and now it works.

Best regards, Wolfgang