EntityManager
classin packageklyn.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, entities=[User]):
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.
Methods
Modifier and Type Member Description
public beforeQuery
beforeQuery() as Void:
Flushes pending changes before managed query I/O in AUTO mode.
public beginTransaction
beginTransaction() as EntityTransaction:
Begins the transaction bound to this manager's provider session.
public clear
clear() as Void:
Detaches every entity from this persistence context.
public close
close() as Void:
Closes the provider session and invalidates manager-owned repositories.
public completeSQLMaterialization
completeSQLMaterialization() as Void:
Resolves deferred eager relationships after root SQL resources close.
public completeSQLMaterialization
completeSQLMaterialization(fetchPaths as IList<String>) as Void:
Completes eager loading and the explicit fetch graph for one SQL result.
public detach
detach<T>(entity as T) as Void:
Stops tracking one entity and its explicit CascadeType.DETACH graph.
public find
find<T, TId>(id as TId) as T:
Finds an entity by its mapped identity.
public loadRelationshipForAccess
loadRelationshipForAccess( entity as Object, propertyPath as String ) as Object:
Resolves one relation requested by a generated lazy property getter.
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 refresh
refresh<T>(entity as T) as Void:
Reloads one managed entity from its provider state.
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 sqlExecute
sqlExecute( sql as String, parameters as klyn.data.sql.SQLParameters = klyn.data.sql.SQLParameters() ) as Long:
Executes one parameterized raw SQL mutation in the active transaction.
public sqlQuery Creates a re-executable typed raw SQL query.
public trackSQL
trackSQL(entity as Object, mapping as SQLMappedEntity) as Object:
Resolves a materialized SQL entity through this manager's identity map.
public withoutPolicy
withoutPolicy( policy as Type, authorization as PolicyAuthorization ) as PolicyScope:
Opens an authorized lexical scope that omits one mandatory policy.
Inherited Methods
methodInherited Methods from AutoClosable: close