Class BeforeSaveEvent<E>

All Implemented Interfaces:
Serializable, ResolvableTypeProvider, RelationalEvent<E>, WithAggregateChange<E>, WithEntity<E>

public class BeforeSaveEvent<E> extends RelationalSaveEvent<E>
Gets published before changes are applied to the database, after the aggregate was converted to a database change.

The persisting process works as follows:

  1. A decision is made, if the aggregate is new and therefore should be inserted or if it is not new and therefore should be updated.
  2. BeforeConvertCallback and BeforeConvertEvent get published.
  3. An AggregateChange object is created for the aggregate. It includes the DbAction instances to be executed. This means that all the deletes, updates and inserts to be performed are determined. These actions reference entities of the aggregates in order to access values to be used in the SQL statements. This step also determines if the id of an entity gets passed to the database or if the database is expected to generate that id.
  4. BeforeSaveCallback and BeforeSaveEvent get published.
  5. SQL statements get applied to the database.
  6. AfterSaveCallback and AfterSaveEvent get published.
Author:
Jens Schauder
See Also:
  • Constructor Details

    • BeforeSaveEvent

      public BeforeSaveEvent(E instance, AggregateChange<E> change)
      Parameters:
      instance - the entity about to get saved. Must not be null.
      change - the AggregateChange that is going to get applied to the database. Must not be null.