From 26f70bf1f002ac34f47a42bf06268f754ef0df6c Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 8 Dec 2017 14:15:02 +0100 Subject: [PATCH] DATAJPA-931 - Avoid unnecessary merging on save. Checking if entity is already attached to entity manager before calling merge. Fixed one test that was relying on the implicit flush triggered by the save. See also: https://vladmihalcea.com/2016/07/19/jpa-persist-and-merge/ --- .../support/SimpleJpaRepository.java | 5 +++- .../support/AuditingEntityListenerTests.java | 5 +++- .../support/SimpleJpaRepositoryUnitTests.java | 25 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java b/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java index df7c0d6fc..98a19911a 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java @@ -66,6 +66,7 @@ import org.springframework.util.Assert; * @author Mark Paluch * @author Christoph Strobl * @author Stefan Fussenegger + * @author Jens Schauder * @param the type of the entity to handle * @param the type of the entity's identifier */ @@ -487,9 +488,11 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation