-
Notifications
You must be signed in to change notification settings - Fork 132
#215 - Add support for EntityCallbacks #397
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[[r2dbc.entity-callbacks]] | ||
= Store specific EntityCallbacks | ||
|
||
Spring Data R2DBC uses the `EntityCallback` API and reacts on the following callbacks. | ||
|
||
.Supported Entity Callbacks | ||
[%header,cols="4"] | ||
|=== | ||
| Callback | ||
| Method | ||
| Description | ||
| Order | ||
|
||
| BeforeConvertCallback | ||
| `onBeforeConvert(T entity, SqlIdentifier table)` | ||
| Invoked before a domain object is converted to `OutboundRow`. | ||
| `Ordered.LOWEST_PRECEDENCE` | ||
|
||
| AfterConvertCallback | ||
| `onAfterConvert(T entity, SqlIdentifier table)` | ||
| Invoked after a domain object is loaded. + | ||
Can modify the domain object after reading it from a row. | ||
| `Ordered.LOWEST_PRECEDENCE` | ||
|
||
| BeforeSaveCallback | ||
| `onBeforeSave(T entity, OutboundRow row, SqlIdentifier table)` | ||
| Invoked before a domain object is saved. + | ||
Can modify the target, to be persisted, `OutboundRow` containing all mapped entity information. | ||
| `Ordered.LOWEST_PRECEDENCE` | ||
|
||
| AfterSaveCallback | ||
| `onAfterSave(T entity, OutboundRow row, SqlIdentifier table)` | ||
| Invoked before a domain object is saved. + | ||
Can modify the domain object, to be returned after save, `OutboundRow` containing all mapped entity information. | ||
| `Ordered.LOWEST_PRECEDENCE` | ||
|
||
|=== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the naming of
BeforeConvertCallback
andAfterConvertCallback
highly confusing.The names suggests that they happen relative to the same process, one before and one after, while in fact they are completely unrelated.
I think
AfterLoadCallback
would be a much better name for theAfterConvertCallback
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AfterLoad
is typically used before converting objects into an entity. We should rather stick to this convention for consistency across our modules.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I don't think we are doing it this way in Spring Data JDBC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should align JDBC to the other stores so we can later on introduce a
AfterLoad
event/callback that gives users a chance to react to values before materializing an object.