EntityClass
The entry point for the entities of one table: creating, finding, and deleting them.
Declare it as the companion object of the entity, normally through the variant matching the id type (IntEntityClass, LongEntityClass, UuidEntityClass, CompositeEntityClass, ...):
class Film(id: EntityID<Int>) : IntEntity(id) {
var title by Films.title
companion object : IntEntityClass<Film>(Films)
}
suspendTransaction {
val film = Film.newSuspend { title = "A New Hope" }
val titles = Film.all().toList().map { it.title }
Film.findById(film.id.value)?.delete()
}Parameters
The table whose rows are mapped to entities managed by this class.
The Entity class to map. Defaults to the class that encloses this companion object.
Called to instantiate an entity for a row. Defaults to the entity's primary constructor, looked up by reflection on first access; pass a reference such as ::Film to skip that lookup.
Inheritors
Constructors
Properties
The columns that this EntityClass depends on when maintaining relations with managed Entity instances.
The IdTable that this EntityClass depends on when maintaining relations with managed Entity instances.
Functions
Gets all the Entity instances associated with this EntityClass.
Registers a reference as an immutable field of the parent entity class, which returns a child object of this EntityClass.
Returns a SizedIterable containing all entities with EntityID values from the provided ids list.
Returns a SizedIterable containing all entities with id values from the provided ids list.
Returns whether the entityClass type is equivalent to or a superclass of this EntityClass instance's klass.
Returns an EntityFieldWithTransform delegate that caches the transformed value on first read of this same stored Unwrapped value.
Returns an EntityFieldWithTransform that extends transformation of an existing EntityFieldWithTransform and caches the transformed value on first read.
Creates a new Entity instance with the fields set in the init block, schedules its insert, flushes the entity cache, and returns the fully-hydrated entity with its auto-generated id and database-generated columns populated.
Composite/explicit-id variant of newSuspend: creates a new Entity instance with the fields set in the init block and with the provided id, schedules its insert, flushes the entity cache, and returns the fully-hydrated entity.
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.
Registers an optional reference as a field of the child entity class, which returns a parent object of this EntityClass.
Composite-FK form of optionalReferencedOn. R2DBC counterpart of JDBC's optionalReferencedOn(IdTable<*>).
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.
Registers a reference as a field of the child entity class, which returns a parent object of this EntityClass.
Composite-FK form of referencedOn. R2DBC counterpart of JDBC's referencedOn(IdTable<*>).
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.
Removes the specified entity from the current EntityCache, as well as any stored references to or from the removed entity.
Returns a Query to select all columns in dependsOnTables with a WHERE clause that includes the provided op conditional expression.
Returns an EntityFieldWithTransform delegate that transforms this stored Unwrapped value on every read.
Returns an EntityFieldWithTransform that extends transformation of an existing EntityFieldWithTransform.
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.
Returns a list of retrieved Entity instances whose refColumn optionally matches any of the id values in references.
Returns a list of retrieved Entity instances whose refColumn matches any of the id values in references.
Returns a SizedIterable containing entities generated using data retrieved from a database result set in rows.