annotation Athena::ORM::Annotations::JoinColumn
#
Configures the foreign key column of the owning side of a AORMA::OneToOne or AORMA::ManyToOne association, or of the join table of a AORMA::ManyToMany association.
@[AORMA::ManyToOne]
@[AORMA::JoinColumn(name: "author_id", referenced_column_name: "id")]
property author : User? = nil
On a AORMA::ManyToMany association, it configures the join table column referencing this entity, while AORMA::InverseJoinColumn configures the one referencing the target entity.
Configuration#
Optional Arguments#
name#
Type: String? Default: see below
The name of the foreign key column.
On a AORMA::OneToOne or AORMA::ManyToOne association, it defaults to the name of the property followed by _id.
On a join table, it defaults to the snake case name of this entity's class followed by _id.
Wrap it in backticks if it needs to be quoted, see Quoting Reserved Words.
referenced_column_name#
Type: String? Default: "id"
The name of the column the foreign key references.
nullable#
Type: Bool? Default: true
Whether the association may be empty, i.e. its column NULL.
When flushing entities that reference each other in a cycle, a nullable column allows inserting them with NULL first and setting the column afterwards.
Join table columns are never nullable.
unique#
Type: Bool Default: false
Whether the column's values must be unique.
Todo
Only used to generate a schema, which isn't supported yet; it's ignored.
deferrable#
Type: Bool Default: false
Whether the foreign key constraint can be deferred until the end of the transaction.
Todo
Only used to generate a schema, which isn't supported yet; it's ignored.
on_delete#
Type: String? Default: nil
The ON DELETE action of the foreign key constraint, e.g. "CASCADE" or "SET NULL".
On a AORMA::ManyToMany association, "CASCADE" tells the ORM that the database deletes the join table rows of a removed entity, so it doesn't delete them itself.
Todo
Otherwise only used to generate a schema, which isn't supported yet.
column_definition#
Type: String? Default: nil
The SQL declaring the column, from after its name.
Todo
Only used to generate a schema, which isn't supported yet; it's ignored.