Class IdGeneratingEntityCallback

java.lang.Object
org.springframework.data.r2dbc.convert.IdGeneratingEntityCallback
All Implemented Interfaces:
EntityCallback<Object>, BeforeSaveCallback<Object>

public class IdGeneratingEntityCallback extends Object implements BeforeSaveCallback<Object>
Callback for generating identifier values through a database sequence.
Since:
3.5
Author:
Mikhail Polivakha, Mark Paluch
  • Constructor Details

    • IdGeneratingEntityCallback

      public IdGeneratingEntityCallback(MappingContext<org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> context, R2dbcDialect dialect, DatabaseClient databaseClient)
  • Method Details

    • onBeforeSave

      public Mono<Object> onBeforeSave(Object entity, OutboundRow row, org.springframework.data.relational.core.sql.SqlIdentifier table)
      Description copied from interface: BeforeSaveCallback
      Entity callback method invoked before a domain object is saved. Can return either the same or a modified instance of the domain object and can modify OutboundRow contents. This method is called after converting the entity to a OutboundRow so effectively the row is used as outcome of invoking this callback. Changes to the domain object are not taken into account for saving, only changes to the row. Only transient fields of the entity should be changed in this callback. To change persistent the entity before being converted, use the BeforeConvertCallback.
      Specified by:
      onBeforeSave in interface BeforeSaveCallback<Object>
      Parameters:
      entity - the domain object to save.
      row - OutboundRow representing the entity.
      table - name of the table.
      Returns:
      the domain object to be persisted.