Skip to content

abstract class Athena::ORM::Mapping::Association
inherits Reference #

Base class for all association mappings. Contains common properties shared by all association types.

An association mapping describes an association property, as configured by AORMA::OneToOne, AORMA::ManyToOne, AORMA::OneToMany, or AORMA::ManyToMany. The mappings of an entity are available from its class metadata:

mapping = em.class_metadata(User).association_mappings["groups"]

mapping.target_entity    # => Group
mapping.cascade_persist? # => true

Each mapping is either an AORM::Mapping::OwningSide or an AORM::Mapping::InverseSide, and includes the module of its kind: AORM::Mapping::OneToOne, AORM::Mapping::ManyToOne, AORM::Mapping::OneToMany, or AORM::Mapping::ManyToMany.

Direct known subclasses

Athena::ORM::Mapping::InverseSide Athena::ORM::Mapping::OwningSide

Methods#

#cascade : Array(String)#

The operations cascaded from the source entity to the target entities, in lower case. "all" in the mapping is expanded to remove, persist, refresh, and detach.

View source

#cascade_detach? : Bool#

Whether AORM::EntityManager#detach cascades to the target entities.

View source

#cascade_persist? : Bool#

Whether AORM::EntityManager#persist cascades to the target entities.

View source

#cascade_remove? : Bool#

Whether AORM::EntityManager#remove cascades to the target entities.

View source

#fetch_mode : FetchMode | ::Nil#

The fetch strategy for loading the association.

Todo

The fetch mode is recorded, but doesn't affect loading yet; see AORM::Mapping::FetchMode.

View source

#fetch_mode=(fetch_mode : FetchMode | Nil)#

The fetch strategy for loading the association.

Todo

The fetch mode is recorded, but doesn't affect loading yet; see AORM::Mapping::FetchMode.

View source

#field_name : String#

The name of the field in the entity that holds this association.

View source

#field_name=(field_name : String)#

The name of the field in the entity that holds this association.

View source

#id=(id : Bool | Nil)#

Whether this association is part of the identifier.

View source

#id? : Bool | ::Nil#

Whether this association is part of the identifier.

View source

#on_delete_cascade=(on_delete_cascade : Bool)#

Whether the database deletes the join table rows of a removed entity on its own, because the association's join columns are declared ON DELETE CASCADE. Default many-to-many join columns are, as are those given on_delete: "CASCADE".

View source

#on_delete_cascade? : Bool#

Whether the database deletes the join table rows of a removed entity on its own, because the association's join columns are declared ON DELETE CASCADE. Default many-to-many join columns are, as are those given on_delete: "CASCADE".

View source

#orphan_removal=(orphan_removal : Bool)#

Whether a target entity that's no longer referenced through this association is removed on flush. Enabling it also cascades remove operations.

View source

#orphan_removal? : Bool#

Whether a target entity that's no longer referenced through this association is removed on flush. Enabling it also cascades remove operations.

View source

#source_entity : AORM::Entity.class#

The entity class that declares this association.

View source

#source_entity=(source_entity : AORM::Entity.class)#

The entity class that declares this association.

View source

#target_entity : AORM::Entity.class#

The entity class this association references.

View source

#target_entity=(target_entity : AORM::Entity.class)#

The entity class this association references.

View source

#type : String#

Returns the kind of association: "one_to_one", "many_to_one", "one_to_many", or "many_to_many".

Todo

Make this an enum

View source

#unique=(unique : Bool | Nil)#

Whether the association should be unique.

View source

#unique? : Bool | ::Nil#

Whether the association should be unique.

View source