2.1. Persistence in Applications

The principal tenet of persistence is to save something to non-volatile storage, which can be a file, a disk, or flash memory, such that if a system is power cycled or an application is restarted, it is possible to retrieve what was previously stored.

A persistence mechanism can either be implemented by an application itself or can be made persistent magically by the operating system, for instance. Thanks to object-oriented programming, it is easy to implement the first case in a helper class that can read and write all basic types like int, short, byte, boolean, String, Date, and so on.

Such a helper class works as an adapter between the storage media and the object contents. If an interface is used for all classes ...

Get Core Java™ Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.