Skip to content

Commit

Permalink
DATAJPA-30 - Added support for 'NotIn' keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrotbohm committed Feb 23, 2011
1 parent e48ec42 commit 44979ac
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ root.<Comparable> get(part.getProperty().toDotPath()),
return path.isNull();
case IS_NOT_NULL:
return path.isNotNull();
case NOT_IN:
return builder.not(path.in(nextAsCollection(iterator)));
case IN:
return path.in(nextAsCollection(iterator));
case LIKE:
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Spring Data JPA Changelog
=============================================

Changes in version 1.0.0.M2
----------------------------------------
* Added support for 'Distinct' (DATACMNS-15)
* Added support for 'In' and 'NotIn' (DATAJPA-30)

Changes in version 1.0.0.M1 (2011-02-10) - https://jira.springsource.org/browse/DATAJPA/fixforversion/11786
----------------------------------------
* Moved JPA sepcific code from Hades into Spring Data JPA (functional equivalent of Hades 2.0.2) building on common functionality in Spring Data Commons
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.List;

import org.junit.Before;
Expand Down Expand Up @@ -112,7 +113,7 @@ public void testAndOrFinder() {


@Test
public void executesPagingMethodToPageCorrectly() throws Exception {
public void executesPagingMethodToPageCorrectly() {

Page<User> page =
userRepository
Expand All @@ -124,7 +125,7 @@ public void executesPagingMethodToPageCorrectly() throws Exception {


@Test
public void executesPagingMethodToListCorrectly() throws Exception {
public void executesPagingMethodToListCorrectly() {

List<User> list =
userRepository.findByFirstname("Carter", new PageRequest(0, 1));
Expand All @@ -133,7 +134,7 @@ public void executesPagingMethodToListCorrectly() throws Exception {


@Test
public void testname() throws Exception {
public void executesInKeywordForPageCorrectly() {

Page<User> page =
userRepository.findByFirstnameIn(new PageRequest(0, 1), "Dave",
Expand All @@ -143,4 +144,15 @@ public void testname() throws Exception {
assertThat(page.getTotalElements(), is(2L));
assertThat(page.getTotalPages(), is(2));
}


@Test
public void executesNotInQueryCorrectly() throws Exception {

List<User> result =
userRepository.findByFirstnameNotIn(Arrays.asList("Dave",
"Carter"));
assertThat(result.size(), is(1));
assertThat(result.get(0), is(oliver));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.jpa.repository.sample;

import java.util.Collection;
import java.util.List;

import javax.persistence.QueryHint;
Expand Down Expand Up @@ -136,6 +137,9 @@ List<User> findByEmailAddressAndLastnameOrFirstname(String emailAddress,
Page<User> findByFirstnameIn(Pageable pageable, String... firstnames);


List<User> findByFirstnameNotIn(Collection<String> firstnames);


/**
* Manipulating query to set all {@link User}'s names to the given one.
*
Expand Down

0 comments on commit 44979ac

Please sign in to comment.