Skip to content

Inconsistent JdbcAggregateTemplate#save return value using BeforeSaveCallback #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ctailor2 opened this issue Mar 18, 2022 · 0 comments
Closed
Assignees
Labels
type: bug A general bug

Comments

@ctailor2
Copy link
Contributor

ctailor2 commented Mar 18, 2022

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.

@ctailor2 ctailor2 self-assigned this Mar 18, 2022
@ctailor2 ctailor2 added the type: bug A general bug label Mar 18, 2022
@ctailor2 ctailor2 changed the title JdbcAggregateTemplate#save return value behavior is not consistent Inconsistent JdbcAggregateTemplate#save return value using BeforeSaveCallback Mar 18, 2022
schauder added a commit that referenced this issue Mar 29, 2022
Formatting and comments.

See #1201
See #1199
Original pull request #1208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant