DATAJPA-332 - Optimization for SimpleJpaRepository.findAll(…) taking Iterable.
We now shortcut the execution of SimpleJpaRepository.findAll(Iterable<Integer> ids) to return an empty collection in case no ids or null are given. Previously building a query with an IN clause failed with an empty parameter list given.
This commit is contained in:
@@ -24,6 +24,7 @@ import static org.springframework.data.jpa.domain.sample.UserSpecifications.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -1049,6 +1050,16 @@ public class UserRepositoryTests {
|
||||
assertThat(repository.countUsersByFirstname("Dave"), is(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-332
|
||||
*/
|
||||
@Test
|
||||
public void findAllReturnsEmptyIterableIfNoIdsGiven() {
|
||||
|
||||
assertThat(repository.findAll(Collections.<Integer> emptySet()), is(emptyIterable()));
|
||||
assertThat(repository.findAll((Iterable<Integer>) null), is(emptyIterable()));
|
||||
}
|
||||
|
||||
private Page<User> executeSpecWithSort(Sort sort) {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
Reference in New Issue
Block a user