-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add after-save entity callbacks support [DATAES-771] #1344
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
Comments
sothawo commented This is a duplicate of DATAES-587. The fact that currently only the before-convert callback is implemented, is because this was needed to implement auditing. We should not add single calbacks one by one, but make a complete solution for that |
Roman Puchkovskiy commented Ok, while I was publishing the following pull request for this issue https://github.com/spring-projects/spring-data-elasticsearch/pull/414 the issue got closed. How should we proceed? I'm interested in adding after-save and after-convert callbacks for the use case mentioned above |
sothawo commented Please first check Jira if there is already an issue for a problem you have. If not, create it first so that there is time to discuss an issue. It is always hard to judge an issue and PR, if the issue is submitted together with an already implemented PR |
sothawo commented as callbacks process entities - and return possibly modified ones, on what should an after-convert callback operate? |
Roman Puchkovskiy commented I'm sorry, it's my bad that I did not search for a Jira ticket. Actually, I am ready to rename the branch and re-create a PR, if needed, to 'migrate' them to DATAES-587. It's just that I don't know what is the best course of action right now.
As for your question on after-convert: I've tried to model callbacks on what events exist in spring-data-mongodb. For the load path, they have after-load (that is given a BSON Document and entity type, but not the entity as it is not yet materialized at this stage) and after-convert (that is given the BSON Document and the materialized entity). In spring-data-elasticsearch, there is an abstraction also called Document that seems to be similar to the MongoDB's counterpart. For example, the
GetResponse response = execute(client -> client.get(request, RequestOptions.DEFAULT));
Document is conceptually a Map (like MongoDB's Document) that contains the document data. So it seems natural to take the same decisions: give both Document and the entity materialized from it to after-save callback (and index name, probably) |
sothawo commented Leave this PR and this ticket, all merge this later. DATAES-587 is a more general one. It probably makes more sense to add new tickets for new callbacks/events, and add them as related to that ticket and then close 587 when all the stuff is done. As for other callbacks: after-load is ok, as there is an entity loaded that can be passed through the callback. About callbacks that would be operating on the Document: The So for me the question is: why should we expose this document after it is created from an entity? If there is the need to do some customization on it, I'd rather prefer that the entity can be modified (annotations) to produce the desired output than to give the user an interface where she needs to hack a solution into the document. For the time being I would not add callbacks operating on the document until the need comes up and can be discussed in detail
|
Roman Puchkovskiy commented As you suggested to create a ticket per new callback type, I've created DATAES-772 and I suggest to move there with the discussion of 'after-convert' callback |
Roman Puchkovskiy opened DATAES-771 and commented
At the moment of writing (2020-03-28), spring-data-elasticsearch only supports before-convert callbacks.
after-save callbacks are implemented in spring-data-mongodb. A justification for their usefulness can be found here: https://jira.spring.io/browse/DATAMONGO-2479?focusedCommentId=188194&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-188194
I'm going to publish a pull request implementing after-save callbacks (both reactive and non-reactive flavors)
Affects: 4.0 RC1 (Neumann)
Issue Links:
Referenced from: pull request #414
The text was updated successfully, but these errors were encountered: