TObjectManager Class
The central object manager for TMS Aurelius, providing persistence, retrieval, and lifecycle management for entity objects against a relational database.
Remarks
TObjectManager is the main entry point for all ORM operations. It maintains an internal identity map so that each entity is loaded only once per manager instance: two queries returning the same entity identifier return the same object reference.
Changes made to managed entities are tracked automatically, and a single call to Flush persists all accumulated changes to the database.
TObjectManager also controls object ownership: when OwnsObjects is True (the default), all managed entities are destroyed when the manager is destroyed.
Syntax
Unit: Aurelius.Engine.ObjectManager
TObjectManager = class(TAbstractManager);
Constructors
| Name | Description |
|---|---|
| Create | Creates a new TObjectManager instance connected to the specified database. |
Destructors
| Name | Description |
|---|---|
| Destroy | Destroys the object manager and, when OwnsObjects is True, frees all managed entities. |
Methods
| Name | Description |
|---|---|
| AddOwnership | Transfers ownership of an entity to the manager so it will be destroyed with the manager, regardless of the outcome of subsequent persistence operations. |
| ApplyUpdates | Executes all deferred SQL statements that were accumulated while CachedUpdates was True. |
| Clear | Removes all entities from the manager's cache without deleting them from the database. |
| CreateCriteria | Overloaded CreateCriteria<E> CreateCriteria(TClass) |
| DisableFilter | Disables the named query filter for this manager. |
| EnableFilter | Enables the named query filter for this manager and returns its configuration handle. |
| Evict | Detaches an entity from the manager without deleting it from the database. |
| FilterEnabled | Overloaded FilterEnabled(string) FilterEnabled(string, TEnabledFilter) |
| Find | Overloaded Find<E> Find<E>(Variant) Find<E>(TGUID) Find(TClass) Find(TClass, Variant) |
| FindCached | Overloaded FindCached<E>(Variant) FindCached(TClass, Variant) |
| Flush | Overloaded Flush Flush(TObject) |
| HasChanges | Overloaded HasChanges HasChanges(TObject) |
| IsAttached | Returns True if the specified entity is currently attached (persistent) in this manager. |
| IsCached | Overloaded IsCached<E>(Variant) IsCached(TClass, Variant) |
| Merge<E> | Merges a transient entity into the manager, returning the corresponding persistent instance. |
| Refresh | Reloads an entity's properties from the database, discarding any in-memory changes. |
| Remove | Removes an entity from the database and detaches it from the manager. |
| Replicate<E> | Replicates a transient entity into the manager, returning the corresponding persistent instance. |
| Save | Saves (inserts) a new entity into the database. |
| SaveOrUpdate | Saves or updates an entity depending on whether it has an identifier value. |
| Update | Attaches a transient entity to the manager so that subsequent Flush calls will persist its current state to the database. |
| Validate | Validates the entity against all constraints defined in the mapping model. |
Properties
| Name | Description |
|---|---|
| BatchSize | Gets or sets the maximum number of records that can be grouped into a single batch SQL statement. |
| CachedCount | Gets the number of SQL actions currently pending in the deferred-update cache. |
| CachedUpdates | Gets or sets whether SQL statements are deferred until ApplyUpdates is called. |
| DeferDestruction | Gets or sets whether removed entities are held in memory until the manager is destroyed, rather than being freed immediately. |
| Explorer | Gets the TMappingExplorer that provides mapping metadata for this manager. |
| ObjectFactory | Gets or sets the factory used to create entity instances during loading operations. |
| OwnsObjects | Gets or sets whether the manager destroys managed entities when it is destroyed. |
| ProxyListLoadDepth | Gets or sets the maximum depth at which many-valued lazy associations are automatically loaded. |
| ProxyLoadDepth | Gets or sets the maximum depth at which single-valued lazy associations are automatically loaded. |
| SQLGenerator | Gets the SQL generator used by this manager to produce SQL statements. |
| UseTransactions | Gets or sets whether the manager automatically wraps operations in database transactions. |
| ValidationsEnabled | Gets or sets whether entity validation is performed automatically before insert and update operations. |