From 9ca86ee2ba21e915b5fb58f324b2f2ce1acd2036 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Thu, 12 Nov 2020 15:59:02 +0100 Subject: [PATCH 1/4] DATAGRAPH-1428 - Prepare branch --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fc4c44187e..29e2e2135b 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.springframework.data spring-data-neo4j - 6.1.0-SNAPSHOT + 6.1.0-DATAGRAPH-1428-SNAPSHOT Spring Data Neo4j Next generation Object-Graph-Mapping for Spring Data. @@ -116,7 +116,7 @@ ${skipTests} ${skipTests} - 2.5.0-SNAPSHOT + 2.4.0-DATACMNS-800-SNAPSHOT ../../../../spring-data-commons/src/main/asciidoc From 02b2b6562ff28c98a4aa5da80f1420ac952abc5a Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Mon, 23 Nov 2020 09:43:24 +0100 Subject: [PATCH 2/4] DATAGRAPH-1428 - Allow branch-snapshots of Data-Commons in StartupLoggerTest, too. This allows for development against changes in commons which aren't on master yet. --- .../data/neo4j/repository/config/StartupLoggerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java b/src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java index 00e5ccc6d1..273520c134 100644 --- a/src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java @@ -30,6 +30,6 @@ void startingMessageShouldFit() { String message = new StartupLogger(StartupLogger.Mode.IMPERATIVE).getStartingMessage(); assertThat(message).matches( - "Bootstrapping imperative Neo4j repositories based on an unknown version of SDN with Spring Data Commons v2\\.\\d+\\.\\d+.(RELEASE|SNAPSHOT) and Neo4j Driver v4\\.\\d+\\.\\d+(?:-.*)\\."); + "Bootstrapping imperative Neo4j repositories based on an unknown version of SDN with Spring Data Commons v2\\.\\d+\\.\\d+.(RELEASE|(?:DATACMNS-\\d+-)?SNAPSHOT) and Neo4j Driver v4\\.\\d+\\.\\d+(?:-.*)\\."); } } From e533a75a383500aeb5704f3147f5e2a50a57ac3b Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Thu, 12 Nov 2020 16:47:14 +0100 Subject: [PATCH 3/4] DATAGRAPH-1428 - Implement deleteAllById(Iterable ids). --- .../repository/support/SimpleNeo4jRepository.java | 8 ++++++++ .../support/SimpleReactiveNeo4jRepository.java | 10 ++++++++++ .../neo4j/integration/imperative/RepositoryIT.java | 13 +++++++++++++ .../integration/reactive/ReactiveRepositoryIT.java | 8 ++++++++ 4 files changed, 39 insertions(+) diff --git a/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java index da64763d21..6737661b2a 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java @@ -43,6 +43,7 @@ * @author Gerrit Meier * @author Michael J. Simons * @author Ján Šúr + * @author Jens Schauder * @since 6.0 * @param the type of the domain class managed by this repository * @param the type of the unique identifier of the domain class @@ -168,4 +169,11 @@ public void deleteAll(Iterable entities) { this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType()); } + + @Override + @Transactional + public void deleteAllById(Iterable ids) { + + this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType()); + } } diff --git a/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveNeo4jRepository.java b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveNeo4jRepository.java index e316f58407..d1cc68a844 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveNeo4jRepository.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveNeo4jRepository.java @@ -40,6 +40,7 @@ * * @author Gerrit Meier * @author Michael J. Simons + * @author Jens Schauder * @since 6.0 * @param the type of the domain class managed by this repository * @param the type of the unique identifier of the domain class @@ -195,11 +196,20 @@ public Mono deleteAll() { public Mono deleteAll(Iterable entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); + List ids = StreamSupport.stream(entities.spliterator(), false).map(this.entityInformation::getId) .collect(Collectors.toList()); return this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType()); } + @Override + public Mono deleteAllById(Iterable ids) { + + Assert.notNull(ids, "The given Iterable of ids must not be null!"); + + return this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType()); + } + /* * (non-Javadoc) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll(org.reactivestreams.Publisher) diff --git a/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java index 6480c6a8ba..16b16deff3 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java @@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.tuple; +import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; @@ -1892,6 +1893,18 @@ void deleteAllEntities(@Autowired PersonRepository repository) { assertThat(repository.existsById(id2)).isFalse(); } + @Test // DATAGRAPH-1428 + void deleteAllById(@Autowired PersonRepository repository) { + + PersonWithAllConstructor person3 = new PersonWithAllConstructor(id1, TEST_PERSON1_NAME, TEST_PERSON1_FIRST_NAME, + TEST_PERSON_SAMEVALUE, true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, + Instant.now()); + + repository.deleteAllById(Arrays.asList(person1.getId(), person3.getId())); + + assertThat(repository.findAll()).extracting(PersonWithAllConstructor::getId).containsExactly(id2); + } + @Test void deleteAll(@Autowired PersonRepository repository) { diff --git a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryIT.java index dbe21b6cd6..593bfb2992 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryIT.java @@ -104,6 +104,7 @@ * @author Gerrit Meier * @author Michael J. Simons * @author Philipp Tölle + * @author Jens Schauder */ @ExtendWith(Neo4jExtension.class) @SpringJUnitConfig @@ -1910,6 +1911,13 @@ void deleteAllEntitiesPublisher(@Autowired ReactivePersonRepository repository) .concatWith(repository.existsById(id2)).as(StepVerifier::create).expectNext(false, false).verifyComplete(); } + @Test // DATAGRAPH-1428 + void deleteAllById(@Autowired ReactivePersonRepository repository) { + + repository.deleteAllById(Arrays.asList(person1.getId(), person2.getId())).then(repository.existsById(id1)) + .concatWith(repository.existsById(id2)).as(StepVerifier::create).expectNext(false, false).verifyComplete(); + } + @Test void deleteSimpleRelationship(@Autowired ReactiveRelationshipRepository repository) { try (Session session = createSession()) { From d7aef08cdc0a2fe5d3e295c9cce3ef441077750b Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Tue, 24 Nov 2020 15:08:26 +0100 Subject: [PATCH 4/4] DATAGRAPH-1428 - Save additional person for test. The additional person allows to actually delete multiple persons, without deleting all of them. --- .../data/neo4j/integration/imperative/RepositoryIT.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java index 16b16deff3..bd4dc4c8ae 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java @@ -1900,6 +1900,8 @@ void deleteAllById(@Autowired PersonRepository repository) { TEST_PERSON_SAMEVALUE, true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, Instant.now()); + repository.save(person3); + repository.deleteAllById(Arrays.asList(person1.getId(), person3.getId())); assertThat(repository.findAll()).extracting(PersonWithAllConstructor::getId).containsExactly(id2);