# EntityCache

class EntityCache(transaction: Transaction)

Class responsible for the storage of Entity instances in a specific transaction.

## Constructors

EntityCache
Link copied to clipboard
constructor(transaction: Transaction)

## Types

Companion
Link copied to clipboard
object Companion

## Properties

data
Link copied to clipboard
val data: LinkedHashMap<IdTable<*>, MutableMap<Any, Entity<*>>>

The mapping of IdTables to associated Entity instances (as a mapping of entity id values to entities).

maxEntitiesToStore
Link copied to clipboard
var maxEntitiesToStore: Int

The amount of entities to store in this EntityCache per Entity class.

## Functions

clear
Link copied to clipboard
fun clear(flush: Boolean = true)

Clears this EntityCache of all stored data, including any reference mappings.

clearReferrersCache
Link copied to clipboard
fun clearReferrersCache()

Clears this EntityCache of stored data that maps cached parent entities to their referencing child entities.

find
Link copied to clipboard
fun <ID : Any, T : Entity<ID>> find(f: EntityClass<ID, T>, id: EntityID<ID>): T?

Searches this EntityCache for an Entity by its EntityID value using its associated EntityClass as the key.

findAll
Link copied to clipboard
fun <ID : Any, T : Entity<ID>> findAll(f: EntityClass<ID, T>): Collection<T>

Gets all Entity instances in this EntityCache that match the associated EntityClass.

flush
Link copied to clipboard
fun flush()

Sends all pending inserts and updates for all Entity instances in this EntityCache to the database.

fun flush(tables: Iterable<IdTable<*>>)

Sends all pending inserts and updates for Entity instances in this EntityCache to the database.

getOrPutReferrers
Link copied to clipboard
fun <ID : Any, R : Entity<ID>> getOrPutReferrers(sourceId: EntityID<*>, key: Column<*>, refs: () -> SizedIterable<R>): SizedIterable<R>

Returns a SizedIterable containing all child Entity instances that reference the parent entity with the provided sourceId using the specified key column.

getReferrers
Link copied to clipboard
fun <R : Entity<*>> getReferrers(sourceId: EntityID<*>, key: Column<*>): SizedIterable<R>?

Returns a SizedIterable containing all child Entity instances that reference the parent entity with the provided sourceId using the specified key column.

remove
Link copied to clipboard
fun <ID : Any, T : Entity<ID>> remove(table: IdTable<ID>, o: T)

Removes the specified Entity from this EntityCache using its associated table as the key.

scheduleInsert
Link copied to clipboard
fun <ID : Any, T : Entity<ID>> scheduleInsert(f: EntityClass<ID, T>, o: T)

Stores the specified Entity in this EntityCache as scheduled to be inserted into the database.

scheduleUpdate
Link copied to clipboard
fun <ID : Any, T : Entity<ID>> scheduleUpdate(f: EntityClass<ID, T>, o: T)

Stores the specified Entity in this EntityCache as scheduled to be updated in the database.

store
Link copied to clipboard
fun store(o: Entity<*>)

Stores the specified Entity in this EntityCache.

fun <ID : Any, T : Entity<ID>> store(f: EntityClass<ID, T>, o: T)

Stores the specified Entity in this EntityCache using its associated EntityClass as the key.