Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Persistent New States
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > The OpenAccess ORM Object Lifecycle > Persistent New States

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

The following figure shows the state changes for objects that you make persistent by calling IObjectScope.Add().

Object State Changes—New Persistent Classes

Object State: transient

When you create an instance of a persistence capable class, it is initially in the transient state. Transient instances do not have an object identity and are not associated with an object scope. This means that transient objects do not exhibit transactional behavior.

Object State: persistent new

You can directly turn a transient object instance into a persistent instance by calling the IObjectScope method Add(). Transient objects for which IObjectScope.Add() is called are move to the persistent new state. A persistent new instance is assigned to the calling IObjectScope instance and an object identifier is assigned to the object. Objects in the persistent new state are written to the database when the transaction is committed. If the transaction is rolled back, persistent new objects revert back to transient.

Transient object instances can indirectly become persistent due to the "persistence by reachability" principle. The "persistence by reachability" behavior states that if you reference a transient object from a persistent class, the transient object will become persistent when the transaction for the referencing object is committed. Another way of saying this, is that if a transient instance is under transitive closure of an object then it is made persistent at commit.

Object State: persistent new deleted

If a persistent new instance is deleted, for example by a call toIObjectScope.Remove(), it becomes persistent new deleted. A persistent new deleted instance no longer has an object identity and it loses its association with the object scope. During the transaction's commit or rollback, the persistent new deleted objects revert to transient.

Object State: hollow

During commit a persistent new instance becomes hollow. A hollow instance represents specific data in the data store but the object instance in memory is hollow (empty). You can find more information about hollow objects in Object Resolution.

Object State Changes—New Persistent Classes

The following table shows the state changes that occur as a new object instance of a persistence capable class is manipulated:

Code

State Change

C# Copy Code
scope.Transaction.Begin();
VB .NET Copy Code
scope.Transaction.Begin();

 

C# Copy Code
Customer c1 = new Customer();
VB .NET Copy Code
Dim c1 As New Customer()

A new Customer instance, c1, is created in the "transient" state

C# Copy Code
scope.Add( c1 );
VB .NET Copy Code
scope.Add( c1 );

c1 is moved to the "persistent new" state

C# Copy Code
Customer c2 = new Customer();
scope.Add( c2 );
VB .NET Copy Code
Customer c2 = new Customer();
scope.Add( c2 );

c2 is created in the "transient" state and then moved to the "persistent new" state

C# Copy Code
scope.Remove( c2 );
VB .NET Copy Code
scope.Remove( c2 );

c2 is moved to the "persistent new deleted" state

C# Copy Code
scope.Transaction.Commit();
VB .NET Copy Code
scope.Transaction.Commit();

c1 is stored and moved to the "hollow" state. c2 is not stored and moved to the "transient" state