Adapt repository to List-based interface variants.

Closes #3964
This commit is contained in:
Mark Paluch
2022-02-14 11:07:27 +01:00
parent 28f262309c
commit 43ac1984ab
4 changed files with 18 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 the original author or authors.
* Copyright 2010-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,9 @@ import java.util.List;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.ListCrudRepository;
import org.springframework.data.repository.ListPagingAndSortingRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.QueryByExampleExecutor;
/**
@@ -33,16 +34,8 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
* @author Khaled Baklouti
*/
@NoRepositoryBean
public interface MongoRepository<T, ID> extends PagingAndSortingRepository<T, ID>, QueryByExampleExecutor<T> {
@Override
<S extends T> List<S> saveAll(Iterable<S> entities);
@Override
List<T> findAll();
@Override
List<T> findAll(Sort sort);
public interface MongoRepository<T, ID>
extends ListCrudRepository<T, ID>, ListPagingAndSortingRepository<T, ID>, QueryByExampleExecutor<T> {
/**
* Inserts the given entity. Assumes the instance to be new to be able to apply insertion optimizations. Use the

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 the original author or authors.
* Copyright 2016-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
/**
@@ -32,7 +33,8 @@ import org.springframework.data.repository.reactive.ReactiveSortingRepository;
* @since 2.0
*/
@NoRepositoryBean
public interface ReactiveMongoRepository<T, ID> extends ReactiveSortingRepository<T, ID>, ReactiveQueryByExampleExecutor<T> {
public interface ReactiveMongoRepository<T, ID>
extends ReactiveCrudRepository<T, ID>, ReactiveSortingRepository<T, ID>, ReactiveQueryByExampleExecutor<T> {
/**
* Inserts the given entity. Assumes the instance to be new to be able to apply insertion optimizations. Use the

View File

@@ -135,7 +135,7 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
}
@Override
public Iterable<T> findAllById(Iterable<ID> ids) {
public List<T> findAllById(Iterable<ID> ids) {
Assert.notNull(ids, "The given Ids of entities not be null!");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 the original author or authors.
* Copyright 2016-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,9 @@ import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.subscribers.TestSubscriber;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.data.repository.reactive.RxJava3CrudRepository;
import org.springframework.data.repository.reactive.RxJava3SortingRepository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -222,12 +225,14 @@ public class ConvertingReactiveMongoRepositoryTests {
// assertThat(people).contains(carter, dave);
// }
interface ReactivePersonRepostitory extends ReactiveSortingRepository<ReactivePerson, String> {
interface ReactivePersonRepostitory
extends ReactiveCrudRepository<ReactivePerson, String>, ReactiveSortingRepository<ReactivePerson, String> {
Publisher<ReactivePerson> findByLastname(String lastname);
}
interface RxJava3PersonRepostitory extends RxJava3SortingRepository<ReactivePerson, String> {
interface RxJava3PersonRepostitory
extends RxJava3CrudRepository<ReactivePerson, String>, RxJava3SortingRepository<ReactivePerson, String> {
io.reactivex.rxjava3.core.Flowable<ReactivePerson> findByFirstnameAndLastname(String firstname, String lastname);