Yes, setting a SQL-String as Writeback-Table will not allow you to run an update against it. Example:
- Code: Select all
DBStorage storage = new DBStorage();
storage.setDBAccess(dbAccess);
storage.setWritebackTable("test");
storage.open();
Now when execute a select and an update on this storage the following queries will be executed on the database (with "a" being the primary key):
- Code: Select all
select m.a, m.b, m.c from test m;
update test set b=?, c=? where a=?;
If we set a SQL-String as writeback table:
- Code: Select all
DBStorage storage = new DBStorage();
storage.setDBAccess(dbAccess);
storage.setWritebackTable("(select * from test)");
storage.open();
We get the following queries:
- Code: Select all
select m.a, m.b, m.c from (select * from test) m;
update (select * from test) set b=?, c=? where a=?;
And we see that the update statement cannot work. What you want is to set the from clause and the writeback table to appropriate values:
- Code: Select all
DBStorage storage = new DBStorage();
storage.setDBAccess(dbAccess);
storage.setFromClause("(select * from test)");
storage.setWritebackTable("test");
storage.open();
Which will yield the expected results:
- Code: Select all
select m.a, m.b, m.c from (select * from test) m;
update test set b=?, c=? where a=?;