diff --git a/src/main/java/org/springframework/data/jpa/repository/JpaRepository.java b/src/main/java/org/springframework/data/jpa/repository/JpaRepository.java index 7de37a262..3cd2b165a 100644 --- a/src/main/java/org/springframework/data/jpa/repository/JpaRepository.java +++ b/src/main/java/org/springframework/data/jpa/repository/JpaRepository.java @@ -72,7 +72,7 @@ public interface JpaRepository extends PagingAndSortingRepository, /** * Saves an entity and flushes changes instantly. * - * @param entity + * @param entity entity to be saved. Must not be {@literal null}. * @return the saved entity */ S saveAndFlush(S entity); @@ -80,8 +80,9 @@ public interface JpaRepository extends PagingAndSortingRepository, /** * Saves all entities and flushes changes instantly. * - * @param entities + * @param entities entities to be deleted. Must not be {@literal null}. * @return the saved entities + * @since 2.5 */ List saveAllAndFlush(Iterable entities); @@ -90,7 +91,7 @@ public interface JpaRepository extends PagingAndSortingRepository, * first level cache and the database out of sync. Consider flushing the {@link EntityManager} before calling this * method. * - * @param entities + * @param entities entities to be deleted. Must not be {@literal null}. * @deprecated Use {@link #deleteAllInBatch(Iterable)} instead. */ @Deprecated @@ -101,8 +102,8 @@ public interface JpaRepository extends PagingAndSortingRepository, * first level cache and the database out of sync. Consider flushing the {@link EntityManager} before calling this * method. * - * @param entities - * @since 3.0 + * @param entities entities to be deleted. Must not be {@literal null}. + * @since 2.5 */ void deleteAllInBatch(Iterable entities); @@ -111,8 +112,8 @@ public interface JpaRepository extends PagingAndSortingRepository, * Deletes the entities identified by the given ids using a single query. This kind of operation leaves JPAs first * level cache and the database out of sync. Consider flushing the {@link EntityManager} before calling this method. * - * @param ids - * @since 3.0 + * @param ids the ids of the entities to be deleted. Must not be {@literal null}. + * @since 2.5 */ void deleteAllByIdInBatch(Iterable ids); diff --git a/src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java b/src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java index 82bd3c401..d891af501 100644 --- a/src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java @@ -46,7 +46,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; @@ -60,16 +59,16 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; +import org.springframework.data.domain.ExampleMatcher.*; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Order; -import org.springframework.data.domain.ExampleMatcher.*; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.sample.Address; import org.springframework.data.jpa.domain.sample.Role; import org.springframework.data.jpa.domain.sample.SpecialUser; import org.springframework.data.jpa.domain.sample.User; -import org.springframework.data.jpa.repository.sample.SampleEvaluationContextExtension.SampleSecurityContextHolder; import org.springframework.data.jpa.repository.sample.UserRepository; +import org.springframework.data.jpa.repository.sample.SampleEvaluationContextExtension.SampleSecurityContextHolder; import org.springframework.data.jpa.repository.sample.UserRepository.NameOnly; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -152,8 +151,8 @@ public class UserRepositoryTests { flushTestUsers(); - assertThat(repository.findAllById(asList(firstUser.getId(), secondUser.getId()))).contains(firstUser, - secondUser); + assertThat(repository.findAllById(asList(firstUser.getId(), secondUser.getId()))) // + .containsExactlyInAnyOrder(firstUser, secondUser); } @Test @@ -167,15 +166,15 @@ public class UserRepositoryTests { @Test void savesCollectionCorrectly() throws Exception { - assertThat(repository.saveAll(asList(firstUser, secondUser, thirdUser))).hasSize(3).contains(firstUser, - secondUser, thirdUser); + assertThat(repository.saveAll(asList(firstUser, secondUser, thirdUser))) // + .containsExactlyInAnyOrder(firstUser, secondUser, thirdUser); } - @Test // DATAJPA-1574 + @Test // gh-2148 void savesAndFlushesCollectionCorrectly() { - assertThat(repository.saveAllAndFlush(asList(firstUser, secondUser, thirdUser))).hasSize(3).contains(firstUser, - secondUser, thirdUser); + assertThat(repository.saveAllAndFlush(asList(firstUser, secondUser, thirdUser))) // + .containsExactlyInAnyOrder(firstUser, secondUser, thirdUser); } @Test @@ -183,7 +182,7 @@ public class UserRepositoryTests { assertThat(repository.saveAll(new ArrayList<>())).isEmpty(); } - @Test // DATAJPA-1574 + @Test // gh-2148 void savingAndFlushingEmptyCollectionIsNoOp() { assertThat(repository.saveAllAndFlush(new ArrayList<>())).isEmpty(); } @@ -1114,7 +1113,7 @@ public class UserRepositoryTests { assertThat(user.getEmailAddress()).isEqualTo(savedUser.getEmailAddress()); } - @Test // DATAJPA-1574 + @Test // gh-2148 void saveAllAndFlushShouldSupportReturningSubTypesOfRepositoryEntity() { repository.deleteAll();