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.
-
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) -
I create a SQLContainer instance and set the version column:
TableQuery pictureQuery = new TableQuery(“PICTURE”, pool);
pictureQuery.setVersionColumn(“VERSION”);
pictureContainer = new SQLContainer(pictureQuery); -
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