...
Code Block | ||
---|---|---|
| ||
UpdateableDataContext dataContext = ...; dataContext.executeUpdate(new UpdateScript() { public void run(UpdateCallback callback) { // INSERT INTO table (name,age) VALUES ('Polly the Sheep', -1) callback.insertInto(table).value("name", "Polly the Sheep").value("age", -1)).execute(); // UPDATE table SET age = 10 WHERE name = 'Polly the Sheep' callback.update(table).where("name").eq("Polly the Sheep").value("age", 10)).execute(); // DELETE FROM table WHERE name = 'Polly the Sheep' callback.deleteFrom(table).where("name").eq("Polly the Sheep")).execute(); }; }); |
Notice also that the UpdateScript interface is a single-method-interface (SAM). This means that from Java 8 and forward, you should be able to provide a closure here instead of an anonymous inner class.
See also
You may be interested in:
- Schema and table semantics - to see what it means to "create a table" in different implementations.