Chapter 6. Modelling Objects

Table of Contents
Definition of persistent Objects
Deriving persistent objects

Since ODL is only a minor extension of Ada 95 only the extensions are described below on basis of examples.

The example below (Test.odb) shows a short fragment. It defines the two types X, Object. The type object is defined as a persistent object which is defined in more detail in the private section of the file.

Example 6-1. A minimal Object Model file

package Test  is

   type Object is persistent private;

   type X is new Integer;


   type Object is persistent record
          A,X,Y   : attribute Integer ;                 -- this goes into the DB
          B       : attribute String(1..50) ;           -- this also
          C       : Integer := 2222;                    -- this not
       end record ;

end Test;
Each field of Object can be marked with the keyword attribute. This keyword indicates, that these parameters will be made persistent. All other field will stay transient. Initializers for all fields may be used but they will only be invoked when the object is first created, with the exception, that fields, which are not attributes, will be set to these values when the application loads the objects.

Definition of persistent Objects

This section describes how persistent object are defined in the ODL language.

Object definition clause

This keyword may be used in a type definition of a record. The keyword indicates, that the following record definition defines a persistent object.

Example 6-2. Syntax: persistent object definition

	    'type' <name> 'is' 'persistent' 
	          'record' <attributes;> 'end' 'record'

Attribute Definition Clause

The attribute keyword may only be used within persistent object. Itr allows to indicate those fields which will be stored in the persistent object storage.

Example 6-3. Syntax: Attribute Definition

	    attribue def; ::= <field> <attribute def>
	    field ::= <name list> ':' [ <attribute> ] <type def>
All fields in a persistent object which are not marked as an attribute will not be stored in the object storage.