SQLContainer addItem; How to use?


I’m trying to figure out how to implement the SQLContainer addItem() using the Vaadin Book!

However the description in the book is too brief to get it going sorry!

Please can anybody explain this topic in more detail?

I’ ve the following:

The MyTable table with a number as primary key field PK, a textfield column, and an OPTLOCK timestamp column, nothing more. Just to keep it very basic, okay!

The query is implemented using the TableQuery like:

TableQuery tq = new TableQuery("MyTable",connectionPool,og);

Next comes the SQLContainer:

SQLContainer sqlC = new SQLContainer(tq);

The sqlC instance defines a listener like:

sqlC.addRowIdChangeListener(new RowIdChangeListener() { public void rowIdChange(RowIdChangeEvent event) { System.ouit.println("Old ID: " + event.getOldRowId()); System.out.println("New ID: " + event.getNewRowId()); } }); Next I use:


Now I’ d expect to obtain the actual primary key value of the newly insert row in the MyTable! However all I get is a NullpointerException, but why!?



your code seems correct to me. Could you maybe provide the stack trace, or preferrably set your application log level to finest and provide the logging message and SQL output of the SQLContainer. That would help solving the issue considerably.