Skip to content

Inconsistent JdbcAggregateTemplate#save return value using BeforeSaveCallback #1199

@ctailor2

Description

@ctailor2

The JdbcAggregateTemplate#save method is expected to return the saved aggregate root with the combined result of the following:

  1. Properties set on the aggregate being saved.
  2. Properties that may be set on the aggregate by the BeforeConvertCallback.
  3. Properties that may be set on the aggregate by the BeforeSaveCallback.
  4. Generated ids for entities that form the aggregate.

Currently the AggregateChangeExecutor#execute method that is called from the JdbcAggregateTemplate either returns the entity on the AggregateChange or the entity on a DbAction.InsertRoot action. This yields an instance with the same properties set under most situations but diverges when the BeforeSaveCallback returns a different instance, for example by updating an immutable property. In this scenario, the return value of AggregateChangeExecutor#execute is the aggregate root with the results of (1), (2), and either of (3) OR (4) from the above, depending on whether the @Id annotated property of the root is mutable.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions