Skip to content

Commit 3be006b

Browse files
committed
DATAREST-847 - RepositoryEntityCotroller.saveAndReturn(…) now uses save result.
Previously we handed the original entity to the AfterSaveEvent. This should work in most cases but actually repositories are allowed to return a completely different instance so that we now hand over the instance returned by the repository interaction to avoid potentially occurring issues.
1 parent 56ac72a commit 3be006b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ private ResponseEntity<ResourceSupport> saveAndReturn(Object domainObject, Repos
471471

472472
publisher.publishEvent(new BeforeSaveEvent(domainObject));
473473
Object obj = invoker.invokeSave(domainObject);
474-
publisher.publishEvent(new AfterSaveEvent(domainObject));
474+
publisher.publishEvent(new AfterSaveEvent(obj));
475475

476476
PersistentEntityResource resource = assembler.toFullResource(obj);
477477
HttpHeaders headers = headersPreparer.prepareHeaders(resource);

0 commit comments

Comments
 (0)