company logo

Transient collection

Keywords:  persistence type

Transient collection are used for storing view results or a result collection created by the application for a longer period in an application. Transient collections need more memory but are faster than temporary collections. In contrast to temporary collections, transient collections are used for storing small or medium result sets. Transient collections are the most efficient way for random access on small or medium result collections.

Transient collections are references being defined as property (reference) of an instance (structure) or globally as extent. For defining a transient collection, the transient option must be switched on. Transient collections must have at least one index definition and the created option must be switched off.

Transient collections must be filled by the application (e.g. in the read handler of an appropriate context class) or may refer to a source definition (view), which is automatically executed when accessing the collection. The data source expression or function has to be implemented in the context of the transient collection's data type. For instance properties, the view is evaluated for each instance, when referring to a source.

Subordinated transient collections with source definition are calculated after reading the parent instance, only, when being accessed directly (e.g. calling count() or get() for the transient collection). The first access to the transient collection causes the system to calculate the collection completely, which may take some time.

For global references (extents), the view is executed once, when opening the collection. Global collections are opened as transient extents, when the controlled option is switched on. In this case, the transient extent can be accessed from any property handle opened for the extent in the application. The extent will be removed when closing the database object or database handle for which the extent has been opened. Transient extents are created, when the first property handle referring to the transient extent is opened.

Extents not being defined as controlled are defined for the property handle opened, only, and will be removed when deleting the property handle. This is a simple way of referring to predefined queries.