# UuidEntityClass

abstract class UuidEntityClass<out E : UuidEntity>(table: IdTable<Uuid>, entityType: Class<E>? = null, entityCtor: (EntityID<Uuid>) -> E? = null) : EntityClass<Uuid, E>

Base class representing the EntityClass that manages UuidEntity instances and maintains their relation to the provided table.

#### Parameters

table

The IdTable object that stores rows mapped to entities of this class.

entityType

The expected UuidEntity type. This can be left `null` if it is the class of type argument E provided to this UuidEntityClass instance. If this `UuidEntityClass` is defined as a companion object of a custom `UuidEntity` class, the parameter will be set to this immediately enclosing class by default.

entityCtor

The function invoked to instantiate a UuidEntity using a provided EntityID value. If a reference to a specific constructor or a custom function is not passed as an argument, reflection will be used to determine the primary constructor of the associated entity class on first access. If this `UuidEntityClass` is defined as a companion object of a custom `UuidEntity` class, the constructor will be set to that of the immediately enclosing class by default.

## Constructors

UuidEntityClass
Link copied to clipboard
constructor(table: IdTable<Uuid>, entityType: Class<E>? = null, entityCtor: (EntityID<Uuid>) -> E? = null)

## Properties

dependsOnColumns
Link copied to clipboard
open val dependsOnColumns: List<Column<out Any?>>

The columns that this EntityClass depends on when maintaining relations with managed Entity instances.

dependsOnTables
Link copied to clipboard
open val dependsOnTables: ColumnSet

The IdTable that this EntityClass depends on when maintaining relations with managed Entity instances.

table
Link copied to clipboard
val table: IdTable<Uuid>

## Functions

all
Link copied to clipboard
open fun all(): SizedIterable<E>

Gets all the Entity instances associated with this EntityClass.

backReferencedOn
Link copied to clipboard
@JvmName(name = "backReferencedOnOpt")
infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.backReferencedOn(column: Column<REF?>): ReadOnlyProperty<Entity<Uuid>, Target>
infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.backReferencedOn(column: Column<REF>): ReadOnlyProperty<Entity<Uuid>, Target>
infix fun <TargetID : Any, Target : Entity<TargetID>> EntityClass<TargetID, Target>.backReferencedOn(table: IdTable<*>): ReadOnlyProperty<Entity<Uuid>, Target>

Registers a reference as an immutable field of the parent entity class, which returns a child object of this `EntityClass`.

count
Link copied to clipboard
fun count(op: Op<Boolean>? = null): Long

Counts the amount of Entity instances that conform to the op conditional expression.

find
Link copied to clipboard
fun find(op: () -> Op<Boolean>): SizedIterable<E>
fun find(op: Op<Boolean>): SizedIterable<E>

Gets all the Entity instances that conform to the op conditional expression.

findById
Link copied to clipboard
fun findById(id: Uuid): E?

Gets an Entity by its id value.

open fun findById(id: EntityID<Uuid>): E?

Gets an Entity by its EntityID value.

findByIdAndUpdate
Link copied to clipboard
fun findByIdAndUpdate(id: Uuid, block: (it: E) -> Unit): E?

Gets an Entity by its id value and updates the retrieved entity.

findSingleByAndUpdate
Link copied to clipboard
fun findSingleByAndUpdate(op: Op<Boolean>, block: (it: E) -> Unit): E?

Gets a single Entity that conforms to the op conditional expression and updates the retrieved entity.

findWithCacheCondition
Link copied to clipboard
fun findWithCacheCondition(cacheCheckCondition: E.() -> Boolean, op: () -> Op<Boolean>): Sequence<E>

Searches the current EntityCache for all Entity instances that match the provided cacheCheckCondition. If the cache returns no matches, entities that conform to the provided op conditional expression will be retrieved from the database.

forEntityIds
Link copied to clipboard
open fun forEntityIds(ids: List<EntityID<Uuid>>): SizedIterable<E>

Returns a SizedIterable containing all entities with EntityID values from the provided ids list.

forIds
Link copied to clipboard
fun forIds(ids: List<Uuid>): SizedIterable<E>

Returns a SizedIterable containing all entities with id values from the provided ids list.

get
Link copied to clipboard
operator fun get(id: Uuid): E
operator fun get(id: EntityID<Uuid>): E
isAssignableTo
Link copied to clipboard
fun <ID : Any, T : Entity<ID>> isAssignableTo(entityClass: EntityClass<ID, T>): Boolean

Returns whether the entityClass type is equivalent to or a superclass of this EntityClass instance's klass.

memoizedTransform
Link copied to clipboard
fun <Unwrapped, Wrapped> Column<Unwrapped>.memoizedTransform(transformer: ColumnTransformer<Unwrapped, Wrapped>): EntityFieldWithTransform<Unwrapped, Wrapped>
fun <Unwrapped, Wrapped> Column<Unwrapped>.memoizedTransform(unwrap: (Wrapped) -> Unwrapped, wrap: (Unwrapped) -> Wrapped): EntityFieldWithTransform<Unwrapped, Wrapped>

Returns a EntityFieldWithTransform delegate that will cache the transformed value on first read of this same stored Unwrapped value.

fun <TColumn, Unwrapped, Wrapped> EntityFieldWithTransform<TColumn, Unwrapped>.memoizedTransform(unwrap: (Wrapped) -> Unwrapped, wrap: (Unwrapped) -> Wrapped): EntityFieldWithTransform<TColumn, Wrapped>

Returns a EntityFieldWithTransform that extends transformation of existing EntityFieldWithTransform and caches the transformed value on first read.

new
Link copied to clipboard
open fun new(init: E.() -> Unit): E

Creates a new Entity instance with the fields that are set in the init block. The id will be automatically set.

open fun new(id: Uuid?, init: E.() -> Unit): E

Creates a new Entity instance with the fields that are set in the init block and with the provided id.

optionalBackReferencedOn
Link copied to clipboard
@JvmName(name = "optionalBackReferencedOnOpt")
infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.optionalBackReferencedOn(column: Column<REF?>): OptionalBackReference<TargetID, Target, Uuid, Entity<Uuid>, REF>
infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.optionalBackReferencedOn(column: Column<REF>): OptionalBackReference<TargetID, Target, Uuid, Entity<Uuid>, REF>
infix fun <TargetID : Any, Target : Entity<TargetID>> EntityClass<TargetID, Target>.optionalBackReferencedOn(table: IdTable<*>): OptionalBackReference<TargetID, Target, Uuid, Entity<Uuid>, Any>

Registers an optional reference as an immutable field of the parent entity class, which returns a child object of this `EntityClass` or `null` if no child references the parent entity.

optionalReferencedOn
Link copied to clipboard
infix fun <REF : Any> optionalReferencedOn(column: Column<REF?>): OptionalReference<REF, Uuid, E>
infix fun optionalReferencedOn(table: IdTable<*>): OptionalReference<Any, Uuid, E>

Registers an optional reference as a field of the child entity class, which returns a parent object of this `EntityClass`.

optionalReferrersOn
Link copied to clipboard
infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.optionalReferrersOn(column: Column<REF?>): Referrers<Uuid, Entity<Uuid>, TargetID, Target, REF?>
infix fun <TargetID : Any, Target : Entity<TargetID>> EntityClass<TargetID, Target>.optionalReferrersOn(table: IdTable<*>): Referrers<Uuid, Entity<Uuid>, TargetID, Target, Any?>
fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.optionalReferrersOn(column: Column<REF?>, cache: Boolean = false): Referrers<Uuid, Entity<Uuid>, TargetID, Target, REF?>
fun <TargetID : Any, Target : Entity<TargetID>> EntityClass<TargetID, Target>.optionalReferrersOn(table: IdTable<*>, cache: Boolean = false): Referrers<Uuid, Entity<Uuid>, TargetID, Target, Any?>

Registers an optional reference as an immutable field of the parent entity class, which returns a collection of child objects of this `EntityClass` that all reference the parent.

referencedOn
Link copied to clipboard
infix fun <REF : Any> referencedOn(column: Column<REF>): Reference<REF, Uuid, E>
infix fun referencedOn(table: IdTable<*>): Reference<Any, Uuid, E>

Registers a reference as a field of the child entity class, which returns a parent object of this `EntityClass`.

referrersOn
Link copied to clipboard
infix fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.referrersOn(column: Column<REF>): Referrers<Uuid, Entity<Uuid>, TargetID, Target, REF>
infix fun <TargetID : Any, Target : Entity<TargetID>> EntityClass<TargetID, Target>.referrersOn(table: IdTable<*>): Referrers<Uuid, Entity<Uuid>, TargetID, Target, Any>
fun <TargetID : Any, Target : Entity<TargetID>, REF : Any> EntityClass<TargetID, Target>.referrersOn(column: Column<REF>, cache: Boolean): Referrers<Uuid, Entity<Uuid>, TargetID, Target, REF>
fun <TargetID : Any, Target : Entity<TargetID>> EntityClass<TargetID, Target>.referrersOn(table: IdTable<*>, cache: Boolean): Referrers<Uuid, Entity<Uuid>, TargetID, Target, Any>

Registers a reference as an immutable field of the parent entity class, which returns a collection of child objects of this `EntityClass` that all reference the parent.

reload
Link copied to clipboard
fun reload(entity: Entity<Uuid>, flush: Boolean = false): E?

Reloads the fields of an entity from the database and returns the entity as a new object.

removeFromCache
Link copied to clipboard
fun removeFromCache(entity: Entity<Uuid>)

Removes the specified entity from the current EntityCache, as well as any stored references to or from the removed entity.

searchQuery
Link copied to clipboard
open fun searchQuery(op: Op<Boolean>): Query

Returns a Query to select all columns in dependsOnTables with a WHERE clause that includes the provided op conditional expression.

testCache
Link copied to clipboard
fun testCache(cacheCheckCondition: E.() -> Boolean): Sequence<E>

Searches the current EntityCache for all Entity instances that match the provided cacheCheckCondition.

fun testCache(id: EntityID<Uuid>): E?

Searches the current EntityCache for an Entity by its EntityID value.

transform
Link copied to clipboard
fun <Unwrapped, Wrapped> Column<Unwrapped>.transform(transformer: ColumnTransformer<Unwrapped, Wrapped>): EntityFieldWithTransform<Unwrapped, Wrapped>
fun <Unwrapped, Wrapped> Column<Unwrapped>.transform(unwrap: (Wrapped) -> Unwrapped, wrap: (Unwrapped) -> Wrapped): EntityFieldWithTransform<Unwrapped, Wrapped>

Returns a EntityFieldWithTransform delegate that transforms this stored Unwrapped value on every read.

fun <TColumn, Unwrapped, Wrapped> EntityFieldWithTransform<TColumn, Unwrapped>.transform(unwrap: (Wrapped) -> Unwrapped, wrap: (Unwrapped) -> Wrapped): EntityFieldWithTransform<TColumn, Wrapped>

Returns a EntityFieldWithTransform that extends transformation of existing EntityFieldWithTransform.

view
Link copied to clipboard
inline fun view(op: () -> Op<Boolean>): View<E>

Creates a View or subset of Entity instances, which are managed by this EntityClass and conform to the specified op conditional expression.

warmUpLinkedReferences
Link copied to clipboard
fun <SID : Any> warmUpLinkedReferences(references: List<EntityID<SID>>, linkTable: Table, forUpdate: Boolean? = null, optimizedLoad: Boolean = false): List<E>

Returns a list of retrieved Entity instances whose reference column matches any of the EntityID values in references. Both the entity's source and target reference columns should have been defined in linkTable.

warmUpOptReferences
Link copied to clipboard
fun <SID> warmUpOptReferences(references: List<SID>, refColumn: Column<SID?>, forUpdate: Boolean? = null, orderBy: Array<Pair<Expression<*>, SortOrder>>? = null): List<E>

Returns a list of retrieved Entity instances whose refColumn optionally matches any of the id values in references.

warmUpReferences
Link copied to clipboard
fun <SID> warmUpReferences(references: List<SID>, refColumn: Column<SID>, forUpdate: Boolean? = null, orderBy: Array<Pair<Expression<*>, SortOrder>>? = null): List<E>

Returns a list of retrieved Entity instances whose refColumn matches any of the id values in references.

wrap
Link copied to clipboard
fun wrap(id: EntityID<Uuid>, row: ResultRow?): E

Returns an Entity with the provided EntityID value, or, if an entity was not found in the current EntityCache, creates a new instance using the data in row.

wrapRow
Link copied to clipboard
fun wrapRow(row: ResultRow): E
fun wrapRow(row: ResultRow, alias: Alias<IdTable<*>>): E
fun wrapRow(row: ResultRow, alias: QueryAlias): E

Wraps the specified ResultRow data into an Entity instance.

wrapRows
Link copied to clipboard
fun wrapRows(rows: SizedIterable<ResultRow>): SizedIterable<E>
fun wrapRows(rows: SizedIterable<ResultRow>, alias: Alias<IdTable<*>>): SizedIterable<E>
fun wrapRows(rows: SizedIterable<ResultRow>, alias: QueryAlias): SizedIterable<E>

Returns a SizedIterable containing entities generated using data retrieved from a database result set in rows.