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.
#cascade_detach? : Bool#
Whether AORM::EntityManager#detach cascades to the target entities.
#cascade_persist? : Bool#
Whether AORM::EntityManager#persist cascades to the target entities.
#cascade_remove? : Bool#
Whether AORM::EntityManager#remove cascades to the target entities.
#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.
#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.
#field_name=(field_name : String)#
The name of the field in the entity that holds this association.
#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".
#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".
#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.
#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.
#source_entity=(source_entity : AORM::Entity.class)#
The entity class that declares this association.
#target_entity=(target_entity : AORM::Entity.class)#
The entity class this association references.
#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