From b0a6f926bd44d1033124ad47aa2cd491c66d7a15 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 10 Jul 2020 15:01:36 +0200 Subject: [PATCH] DATAJPA-1754 - Checks that the entity passed to save is not null. Before this change a null value would have yielded an ambiguous exception, instead of a proper IllegalArgumentException. Signed-off-by: Jens Schauder --- .../data/jpa/repository/support/SimpleJpaRepository.java | 2 ++ 1 file changed, 2 insertions(+) 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 6ad9f11e5..3169abe10 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 @@ -550,6 +550,8 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation S save(S entity) { + Assert.notNull(entity, "Entity must not be null."); + if (entityInformation.isNew(entity)) { em.persist(entity); return entity;