annotation Athena::ORM::Annotations::GeneratedValue
#
Has the database generate the value of the entity's identifier.
Only has an effect alongside AORMA::ID.
@[AORMA::Column]
@[AORMA::ID]
@[AORMA::GeneratedValue]
property! id : Int64
The generated identifier is assigned to the entity when it's inserted, during AORM::EntityManager#flush.
It isn't available right after AORM::EntityManager#persist.
Configuration#
Optional Arguments#
strategy#
Type: AORM::Mapping::GeneratedValueStrategy Default: :auto
How the identifier is generated:
:auto- Uses the strategy preferred by the database, which is:identityfor every supported database.:identity- The database generates the value when the row is inserted, e.g. via anAUTO_INCREMENTorGENERATED BY DEFAULT AS IDENTITYcolumn. It's read back withRETURNINGon the databases that support it, and as the last inserted ID otherwise.:none- Your code assigns the identifier before persisting the entity, the same as not applying this annotation.:sequence- The value is taken from a database sequence, seeAORMA::SequenceGenerator.:custom- The value is generated by your own code.
Todo
The :sequence and :custom strategies aren't supported yet; using them raises when the entity's metadata is built.