EntityManager
class in package klyn.data

    public final class EntityManager implements AutoClosable, QuerySynchronizer, SQLIdentityTracker:

EntityManager
All Implemented Interfaces: AutoClosable, QuerySynchronizer, SQLIdentityTracker

Non-thread-safe persistence context for queries and entity lifecycle.

`Repository<T, TId>` is only a typed KQL query root. Key lookup, persistence, merging and removal are centralized here so every provider observes one identity map and one unit-of-work boundary.

    try factory = EntityManagerFactory(configuration):
    try manager = factory.createEntityManager():
    users = manager.repository<User>()
    user = manager.find<User>(1)

Properties

Modifier and Type | Member | Description
--- | --- | ---
public property | flushMode `flushMode as FlushMode:` | Controls synchronization before query execution.
public readonly property | open `open as Boolean:` | Indicates whether this persistence context accepts operations.
public readonly property | transaction `transaction as EntityTransaction` | Transaction bound to this manager's provider session.

Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | EntityManager `EntityManager( configuration as ProviderConfiguration, mappings as MappingRegistry = MappingRegistry.empty ):` | Creates a persistence context for one provider configuration.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | beforeQuery `beforeQuery() as Void:` | Flushes pending changes before managed query I/O in `AUTO` mode.
public | close `close() as Void:` | Closes the provider session and invalidates manager-owned repositories.
public | find `find<T, TId>(id as TId) as T:` | Finds an entity by its mapped identity.
public | merge `merge<T>(entity as T) as T:` | Copies detached state into a managed instance.
public | persist `persist<T>(entity as T) as Void:` | Registers a new entity for insertion.
public | remove `remove<T>(entity as T) as Void:` | Registers a managed entity for deletion.
public | repository `repository<T, TId>( mapping as MappingDescriptor<T, TId> ) as Repository<T, TId>:` | Returns a cached typed KQL query root using an explicit mapping.
public | repository `repository<T, TId>() as Repository<T, TId>:` | Returns a cached typed KQL query root using the default mapping.
public | saveChanges `saveChanges() as Int:` | Synchronizes pending unit-of-work changes with the provider.
public | trackSQL `trackSQL(entity as Object, mapping as SQLMappedEntity) as Object:` | Resolves a materialized SQL entity through this manager's identity map.

Inherited Methods
method Inherited Methods from AutoClosable: close
method Inherited Methods from QuerySynchronizer: beforeQuery
method Inherited Methods from SQLIdentityTracker: trackSQL