Skip to content
Carlo Barazzetta edited this page Dec 4, 2018 · 5 revisions

Primer Demo: Persisting Objects

One of the main issues when building truly object oriented business applications is the ability to persist business objects. InstantObjects addresses this issue by supporting the most common relational databases as object storage. Relations between objects defined in the business model are handled seamlessly by InstantObjects when storing objects to or retrieving objects from the database.

In most cases, object persistence is handled automatically by the presentation components through which the objects are exposed in the user interface. See the Presentation section for more details about object presentation.

When objects are not accessed via the user interface, persistence is achieved by application code instead. 

Business classes inherit their persistent capabilities from TInstantObject. Like other classes in Delphi, instances of classes that descent from TInstantObject are created with the Create constructor of the class. Objects can be stored in the database by invoking the Store method. Existing objects can be retrieved from the database with the Retrieve constructor. When objects are no longer needed, they can be removed from the database by invoking the Dispose method.

Examples of persisting objects by code can be found in the unit DemoData.pas. This unit contains the code for random generation of contacts. Study the code to learn how easy it is to create persistent objects with InstantObjects.

Clone this wiki locally