Skip to content

DATAGRAPH-1428 - Implement deleteAllById(Iterable<ID> ids). #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>6.1.0-SNAPSHOT</version>
<version>6.1.0-DATAGRAPH-1428-SNAPSHOT</version>

<name>Spring Data Neo4j</name>
<description>Next generation Object-Graph-Mapping for Spring Data.</description>
Expand Down Expand Up @@ -116,7 +116,7 @@
<skipIntegrationTests>${skipTests}</skipIntegrationTests>

<skipUnitTests>${skipTests}</skipUnitTests>
<springdata.commons>2.5.0-SNAPSHOT</springdata.commons>
<springdata.commons>2.4.0-DATACMNS-800-SNAPSHOT</springdata.commons>

<spring-data-commons-docs.dir>../../../../spring-data-commons/src/main/asciidoc</spring-data-commons-docs.dir>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* @author Gerrit Meier
* @author Michael J. Simons
* @author Ján Šúr
* @author Jens Schauder
* @since 6.0
* @param <T> the type of the domain class managed by this repository
* @param <ID> the type of the unique identifier of the domain class
Expand Down Expand Up @@ -168,4 +169,11 @@ public void deleteAll(Iterable<? extends T> entities) {

this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType());
}

@Override
@Transactional
public void deleteAllById(Iterable<? extends ID> ids) {

this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*
* @author Gerrit Meier
* @author Michael J. Simons
* @author Jens Schauder
* @since 6.0
* @param <T> the type of the domain class managed by this repository
* @param <ID> the type of the unique identifier of the domain class
Expand Down Expand Up @@ -195,11 +196,20 @@ public Mono<Void> deleteAll() {
public Mono<Void> deleteAll(Iterable<? extends T> entities) {

Assert.notNull(entities, "The given Iterable of entities must not be null!");

List<ID> ids = StreamSupport.stream(entities.spliterator(), false).map(this.entityInformation::getId)
.collect(Collectors.toList());
return this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType());
}

@Override
public Mono<Void> deleteAllById(Iterable<? extends ID> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1892,6 +1893,20 @@ 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.save(person3);

repository.deleteAllById(Arrays.asList(person1.getId(), person3.getId()));

assertThat(repository.findAll()).extracting(PersonWithAllConstructor::getId).containsExactly(id2);
}

@Test
void deleteAll(@Autowired PersonRepository repository) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
* @author Gerrit Meier
* @author Michael J. Simons
* @author Philipp Tölle
* @author Jens Schauder
*/
@ExtendWith(Neo4jExtension.class)
@SpringJUnitConfig
Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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+(?:-.*)\\.");
}
}