Persistence in Object Oriented languages
Figure 833. Persistence [Bauer2015]
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 834. Java™ transient instances
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 835. RDBMS persistent records
CREATE TABLE User(
commonName CHAR(80)
,uid CHAR(10) PRIMARY KEY
);
-- Persistent record (see Durability in ACID)
INSERT INTO User VALUES('Joe Bix', 'bix');