spring-projects / spring-projects/spring-data-rest
Compare two versions of an object. [DATAREST-283]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Juan opened DATAREST-283 and commented
I am trying to validate the changes from one object, the version received through the api rest and the version in the db.
My configuration to call the validator before save it:
@Override
protected void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener v) {
v.addValidator("beforeSave", beforeUpdateCampaignValidator);
}
My validate Method:
@Override
public void validate(Object obj, Errors e) {
Campaign newVal = ((Campaign) obj);
Campaign oldVal = this.campaignRepository.findOne(newVal.getId());
....
....
Some validations
....
....
}
The problem with my validator is the newVal and the oldVal are the same object that comes from the rest api. I also tried using the eventListener (AbstractRepositoryEventListener<T>) with the same result. I figure out the two objects (the old version and the new one) are merged, I guess through DomainObjectMerger (some trace debugging).
Are there any place or method to get the object received in the api rest to compare with the database version?
Thanks in advance
Affects: 2.0 M1 (Codd), 2.0 RC1 (Codd), 2.0 GA (Codd), 2.0.1 (Codd SR1)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.