Skip to content
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

Add AfterLoad lifecycle callback #2009

Closed
goldami1 opened this issue Nov 22, 2021 · 8 comments · Fixed by #2039
Closed

Add AfterLoad lifecycle callback #2009

goldami1 opened this issue Nov 22, 2021 · 8 comments · Fixed by #2039
Assignees
Labels
status: worked on a contributor is working on this issue type: enhancement A general enhancement

Comments

@goldami1
Copy link

goldami1 commented Nov 22, 2021

Hi,

Following #1159 , I suggest to add additionally to the afterSave, afterConvert and beforeSave callbacks, also the beforeLoad.
Similarly to MongoTemplate which emits AfterLoadEvent before the reader is used to read the document (in ReadDocumentCallback).
Thus, Similar functionality would be apprepciated at the Spring Data EntityCallbacks level for both ES and MONGO.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 22, 2021
@sothawo
Copy link
Collaborator

sothawo commented Nov 23, 2021

Spring Data Elasticsearch does not use events, only callbacks. See https://docs.spring.io/spring-data/elasticsearch/docs/4.3.0/reference/html/#entity-callbacks for information about the events and callbacks. Spring Data MongoDB has both, as there the events were already implemented when the callbacks were introduced.

When adding the callbacks we deliberately did not add the events as well.

@sothawo sothawo added the status: waiting-for-feedback We need additional information before we can continue label Nov 23, 2021
@goldami1
Copy link
Author

goldami1 commented Nov 23, 2021

@sothawo that's clear. however, I suggest to add a "beforeLoad" callback invocation right before the Document is read into a domain object. (both for spring-data-mongodb and spring-data-elasticsearch projects)

(for example can be named like: maybeCallAfterLoad(document, type, collectionName))

image
image

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 23, 2021
@sothawo sothawo changed the title Add lifecycle events Add beforeLoad lifecycle callback Nov 23, 2021
@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Nov 23, 2021
@sothawo
Copy link
Collaborator

sothawo commented Nov 23, 2021

If it's only the additional callback, that's fine. I can't speak for Spring DataMongo though, you'll need to add an issue there.

@goldami1
Copy link
Author

@sothawo sounds great, will do!
However for spring dataElastic it sounds like a good addition. would appreciate your feedback.

@sothawo
Copy link
Collaborator

sothawo commented Nov 23, 2021

don't forget to add it to the reactive part as well.

@goldami1
Copy link
Author

goldami1 commented Nov 23, 2021

@sothawo ok. can I help with implementation?

@sothawo
Copy link
Collaborator

sothawo commented Nov 23, 2021

Sure. Fork the repo, create a branch form main - or use the main branch of your fork, add the necessary tests and implementation (see https://github.com/spring-projects/spring-data-elasticsearch/blob/main/CONTRIBUTING.adoc) and then submit a pull request to have your forked branch be merged into this repo's main.

@sothawo sothawo added the status: worked on a contributor is working on this issue label Nov 24, 2021
@sothawo
Copy link
Collaborator

sothawo commented Dec 17, 2021

@goldami1 are you working on that? This callback could be used to solve the problem of #2029.

@sothawo sothawo changed the title Add beforeLoad lifecycle callback Add AfterLoad lifecycle callback Dec 26, 2021
@sothawo sothawo self-assigned this Dec 26, 2021
sothawo added a commit to sothawo/spring-data-elasticsearch that referenced this issue Dec 26, 2021
sothawo added a commit to sothawo/spring-data-elasticsearch that referenced this issue Dec 26, 2021
sothawo added a commit that referenced this issue Dec 26, 2021
Original Pull Request #2039
Closes #2009
@sothawo sothawo added this to the 4.4 M1 (2021.2.0) milestone Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: worked on a contributor is working on this issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants