From 0b6a0a0a8da5e5a5436ab0dd7bc3ccd71479fa56 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Sat, 25 Jun 2016 14:44:27 +0200 Subject: [PATCH] =?UTF-8?q?DATAREST-847=20-=20RepositoryEntityCotroller.sa?= =?UTF-8?q?veAndReturn(=E2=80=A6)=20now=20uses=20save=20result.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../data/rest/webmvc/RepositoryEntityController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java index 51860b0d8..c7c6a59cf 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java @@ -466,7 +466,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem publisher.publishEvent(new BeforeSaveEvent(domainObject)); Object obj = invoker.invokeSave(domainObject); - publisher.publishEvent(new AfterSaveEvent(domainObject)); + publisher.publishEvent(new AfterSaveEvent(obj)); PersistentEntityResource resource = assembler.toFullResource(obj); HttpHeaders headers = headersPreparer.prepareHeaders(resource);