Skip to content

annotation Athena::ORM::Annotations::Entity #

Marks a class as an entity, whose instances are persisted by the ORM. The class must inherit from AORM::Entity.

@[AORMA::Entity]
class User < AORM::Entity
  @[AORMA::Column]
  @[AORMA::ID]
  @[AORMA::GeneratedValue]
  property! id : Int64

  @[AORMA::Column]
  property! name : String
end

The ORM never calls an entity's constructor, so it's free to require any arguments. Entities loaded from the database are allocated with the default values of their instance variables, and then have their mapped instance variables set directly. Mapped instance variables are always read and written directly, so custom logic in getters and setters doesn't apply to the values the ORM loads or persists.

Configuration#

Optional Arguments#

repository_class#

Type: AORM::RepositoryInterface.class Default: nil

The repository AORM::EntityManager#repository returns for this entity, in place of an AORM::EntityRepository. See Custom Repositories.


read_only#

Type: Bool Default: false

Whether changes to managed instances of the entity are ignored when flushing. Read-only entities can still be persisted and removed, and skipping them saves computing their changes on every flush.