liveBook · Manning

Update

As explained in Data-Oriented Programming in Java

An update is a database write description representing changes to an existing record.

An update is a database write description for changing an existing record. It carries a table name and a TableRecord, and travels alongside inserts in a transaction rather than mutating the database directly. section 10.1.1 section 10.4.6

The distinction matters at the database boundary: inserting an existing record or updating a missing one raises an exception. Yet application code may not want to think in those terms at all. If its meaning is “put this data in the database,” an upsert operation can preserve that intent while translating internally into updates and inserts. section 10.4.6

Collecting transactional updates

An update is represented explicitly and grouped with other writes before the database transaction executes: `new Update("ACCOUNTS", TableRecord.builder().set(...).build())`. The application can then pass its update list and insert list to `database.transact(...)`. section 10.1.1

Listing 10.3 Data types used for making changes
record Insert(String table, TableRecord record){}
record Update(String table, TableRecord record){}
 

Shows the compact Java data type used to distinguish updates from inserts. section 10.1.1

How Data-Oriented Programming in Java covers it

How deep it goes
Defines the data shape and existence constraint, but defers database-library implementation details.
Examples
Uses Java Update records collected into lists and passed with inserts to database.transact.
What you can do after
Operate/configure transactional database writes by distinguishing changes to existing records from inserts.
How it connects
Connects updates with Insert, TableRecord, database transactions, and upsert semantics.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.