Skip to content

Commit 43ac198

Browse files
committed
Adapt repository to List-based interface variants.
Closes #3964
1 parent 28f2623 commit 43ac198

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoRepository.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2021 the original author or authors.
2+
* Copyright 2010-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,8 +19,9 @@
1919

2020
import org.springframework.data.domain.Example;
2121
import org.springframework.data.domain.Sort;
22+
import org.springframework.data.repository.ListCrudRepository;
23+
import org.springframework.data.repository.ListPagingAndSortingRepository;
2224
import org.springframework.data.repository.NoRepositoryBean;
23-
import org.springframework.data.repository.PagingAndSortingRepository;
2425
import org.springframework.data.repository.query.QueryByExampleExecutor;
2526

2627
/**
@@ -33,16 +34,8 @@
3334
* @author Khaled Baklouti
3435
*/
3536
@NoRepositoryBean
36-
public interface MongoRepository<T, ID> extends PagingAndSortingRepository<T, ID>, QueryByExampleExecutor<T> {
37-
38-
@Override
39-
<S extends T> List<S> saveAll(Iterable<S> entities);
40-
41-
@Override
42-
List<T> findAll();
43-
44-
@Override
45-
List<T> findAll(Sort sort);
37+
public interface MongoRepository<T, ID>
38+
extends ListCrudRepository<T, ID>, ListPagingAndSortingRepository<T, ID>, QueryByExampleExecutor<T> {
4639

4740
/**
4841
* Inserts the given entity. Assumes the instance to be new to be able to apply insertion optimizations. Use the

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ReactiveMongoRepository.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import org.springframework.data.domain.Sort;
2424
import org.springframework.data.repository.NoRepositoryBean;
2525
import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor;
26+
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
2627
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
2728

2829
/**
@@ -32,7 +33,8 @@
3233
* @since 2.0
3334
*/
3435
@NoRepositoryBean
35-
public interface ReactiveMongoRepository<T, ID> extends ReactiveSortingRepository<T, ID>, ReactiveQueryByExampleExecutor<T> {
36+
public interface ReactiveMongoRepository<T, ID>
37+
extends ReactiveCrudRepository<T, ID>, ReactiveSortingRepository<T, ID>, ReactiveQueryByExampleExecutor<T> {
3638

3739
/**
3840
* Inserts the given entity. Assumes the instance to be new to be able to apply insertion optimizations. Use the

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public List<T> findAll() {
135135
}
136136

137137
@Override
138-
public Iterable<T> findAllById(Iterable<ID> ids) {
138+
public List<T> findAllById(Iterable<ID> ids) {
139139

140140
Assert.notNull(ids, "The given Ids of entities not be null!");
141141

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/ConvertingReactiveMongoRepositoryTests.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,9 @@
2323
import io.reactivex.rxjava3.subscribers.TestSubscriber;
2424
import lombok.Data;
2525
import lombok.NoArgsConstructor;
26+
27+
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
28+
import org.springframework.data.repository.reactive.RxJava3CrudRepository;
2629
import org.springframework.data.repository.reactive.RxJava3SortingRepository;
2730
import reactor.core.publisher.Flux;
2831
import reactor.core.publisher.Mono;
@@ -222,12 +225,14 @@ public void shouldFindByObservableOfLastNameIn() {
222225
// assertThat(people).contains(carter, dave);
223226
// }
224227

225-
interface ReactivePersonRepostitory extends ReactiveSortingRepository<ReactivePerson, String> {
228+
interface ReactivePersonRepostitory
229+
extends ReactiveCrudRepository<ReactivePerson, String>, ReactiveSortingRepository<ReactivePerson, String> {
226230

227231
Publisher<ReactivePerson> findByLastname(String lastname);
228232
}
229233

230-
interface RxJava3PersonRepostitory extends RxJava3SortingRepository<ReactivePerson, String> {
234+
interface RxJava3PersonRepostitory
235+
extends RxJava3CrudRepository<ReactivePerson, String>, RxJava3SortingRepository<ReactivePerson, String> {
231236

232237
io.reactivex.rxjava3.core.Flowable<ReactivePerson> findByFirstnameAndLastname(String firstname, String lastname);
233238

0 commit comments

Comments
 (0)