Interface BeforeConvertCallback<T>

All Superinterfaces:
EntityCallback<T>
All Known Implementing Classes:
RelationalAuditingCallback
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface BeforeConvertCallback<T> extends EntityCallback<T>
An EntityCallback that gets invoked before the aggregate is converted into a database change. The decision if the change will be an insert or update is made before this callback gets called.

This is the correct callback if you want to create Id values for new aggregates.

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.
Since:
1.1
Author:
Jens Schauder, Mark Paluch
  • Method Summary

    Modifier and Type
    Method
    Description
    onBeforeConvert(T aggregate)
    Entity callback method invoked before an aggregate root is converted to be persisted.
  • Method Details

    • onBeforeConvert

      T onBeforeConvert(T aggregate)
      Entity callback method invoked before an aggregate root is converted to be persisted. Can return either the same or a modified instance of the aggregate.
      Parameters:
      aggregate - the saved aggregate.
      Returns:
      the aggregate to be persisted.