Class IdGeneratingEntityCallback
java.lang.Object
org.springframework.data.r2dbc.convert.IdGeneratingEntityCallback
- All Implemented Interfaces:
EntityCallback<Object>
,BeforeSaveCallback<Object>
Callback for generating identifier values through a database sequence.
- Since:
- 3.5
- Author:
- Mikhail Polivakha, Mark Paluch
-
Constructor Summary
ConstructorsConstructorDescriptionIdGeneratingEntityCallback
(MappingContext<RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, R2dbcDialect dialect, DatabaseClient databaseClient) -
Method Summary
Modifier and TypeMethodDescriptiononBeforeSave
(Object entity, OutboundRow row, SqlIdentifier table) Entity callback method invoked before a domain object is saved.
-
Constructor Details
-
IdGeneratingEntityCallback
public IdGeneratingEntityCallback(MappingContext<RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, R2dbcDialect dialect, DatabaseClient databaseClient)
-
-
Method Details
-
onBeforeSave
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 modifyOutboundRow
contents. This method is called after converting theentity
to aOutboundRow
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 theBeforeConvertCallback
.- Specified by:
onBeforeSave
in interfaceBeforeSaveCallback<Object>
- Parameters:
entity
- the domain object to save.row
-OutboundRow
representing theentity
.table
- name of the table.- Returns:
- the domain object to be persisted.
-