prePersist
PrePersist is a lifecycle callback or event in some object-relational mapping frameworks, triggered just before a new entity is persisted (inserted) into the database. It is part of the set of lifecycle events that allow developers to execute custom logic at specific points in an entity’s lifecycle, without manually invoking code around every create operation.
In Java Persistence API (JPA), a method annotated with @PrePersist is invoked before the entity is inserted.
In Doctrine ORM (PHP) and similar frameworks, prePersist serves the same purpose: a method on the entity
Common uses of prePersist include initializing derived or required fields, setting default values that depend on
Notes: prePersist occurs only for new entities and not for updates. It can be complemented by related