Persistence in Object Oriented languages

Figure 817. Persistence [Bauer2015] Slide presentation

Persistence allows an object to outlive the process that created it.

The state of the object may be stored to disk and an object with the same state re-created at some point in the future.


Figure 818. Java transient instances Slide presentation
public class User {
  String commonName; // Common name e.g. 'Joe Bix'
  String uid;        // Unique login name e.g. 'bix'
  ...                // getters, setters and other stuff

}
//------------------------------------
// Thread lifespan (transient instance)
User u = new User("Joe Bix", "bix");

Figure 819. RDBMS persistent records Slide presentation
CREATE TABLE User(
  commonName CHAR(80)
 ,uid CHAR(10) PRIMARY KEY
);
-- Persistent record (see Durability in ACID)
INSERT INTO User VALUES('Joe Bix', 'bix');

Figure 820. Persisting transient User instances Slide presentation
Persisting transient User instances

Figure 821. Observations Slide presentation
  • Processes in disjoint address spaces:

    1. JRE™ runtime.

    2. RDBMS server.

  • Multiple runtimes possible (PHP)

  • save and load denote communications across OS boundaries.