#297 - Upgraded to Boot 2.0 and Spring Data Kay.

Bumped version number to 2.0. Upgraded to Spring Boot 2.0.

Stuff disabled in the meantime:

- Cassandra: needs API adaptions in configuration
- JPA > Security: test fails with weird Hibernate error
- Redis > Reactive: API updates needed
- Solr: configration updates necessary

adjust versions

Updated elastic search to the new version.

Fixed the reactor version to Bismuth-BUILD-SNAPSHOT. This probably should be undone when boot references the proper bom.
This commit is contained in:
Oliver Gierke
2017-05-04 19:28:40 +02:00
parent 90546357c7
commit 4164bc4607
98 changed files with 319 additions and 368 deletions

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-cassandra-examples</artifactId> <artifactId>spring-data-cassandra-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -23,7 +23,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.data.cassandra.config.SchemaAction; import org.springframework.data.cassandra.config.SchemaAction;
import org.springframework.data.cassandra.config.java.AbstractCassandraConfiguration; import org.springframework.data.cassandra.config.java.AbstractCassandraConfiguration;
import org.springframework.data.cassandra.convert.CustomConversions; import org.springframework.data.cassandra.convert.CassandraCustomConversions;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -55,14 +55,14 @@ class ConverterConfiguration extends AbstractCassandraConfiguration {
} }
@Override @Override
public CustomConversions customConversions() { public CassandraCustomConversions customConversions() {
List<Converter<?, ?>> converters = new ArrayList<>(); List<Converter<?, ?>> converters = new ArrayList<>();
converters.add(new PersonWriteConverter()); converters.add(new PersonWriteConverter());
converters.add(new PersonReadConverter()); converters.add(new PersonReadConverter());
converters.add(new CustomAddressbookReadConverter()); converters.add(new CustomAddressbookReadConverter());
return new CustomConversions(converters); return new CassandraCustomConversions(converters);
} }
/** /**

View File

@@ -71,7 +71,7 @@ public class BasicUserRepositoryTests {
user = repository.save(user); user = repository.save(user);
assertThat(repository.findOne(user.getId()), is(user)); assertThat(repository.findById(user.getId()), is(user));
} }
/** /**

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-cassandra-examples</artifactId> <artifactId>spring-data-cassandra-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<name>Spring Data Cassandra - Examples</name> <name>Spring Data Cassandra - Examples</name>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-cassandra-examples</artifactId> <artifactId>spring-data-cassandra-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-cassandra-reactive</artifactId> <artifactId>spring-data-cassandra-reactive</artifactId>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-cassandra-examples</artifactId> <artifactId>spring-data-cassandra-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-elasticsearch-examples</artifactId> <artifactId>spring-data-elasticsearch-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
</project> </project>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<name>Spring Data Elasticsearch - Examples</name> <name>Spring Data Elasticsearch - Examples</name>
@@ -16,7 +16,7 @@
<url>https://github.com/spring-projects/spring-data-elasticsearch</url> <url>https://github.com/spring-projects/spring-data-elasticsearch</url>
<properties> <properties>
<elasticsearch.version>2.2.0</elasticsearch.version> <elasticsearch.version>5.4.0</elasticsearch.version>
</properties> </properties>
<modules> <modules>

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -15,8 +15,7 @@
*/ */
package example.springdata.jpa.eclipselink; package example.springdata.jpa.eclipselink;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import javax.transaction.Transactional; import javax.transaction.Transactional;
@@ -43,6 +42,6 @@ public class CustomerRepositoryIntegrationTests {
Customer dave = customers.save(new Customer("Dave", "Matthews")); Customer dave = customers.save(new Customer("Dave", "Matthews"));
assertThat(customers.findOne(dave.getId()), is(dave)); assertThat(customers.findById(dave.getId())).hasValue(dave);
} }
} }

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -15,6 +15,8 @@
*/ */
package example.springdata.jpa.auditing; package example.springdata.jpa.auditing;
import java.util.Optional;
import org.springframework.data.domain.AuditorAware; import org.springframework.data.domain.AuditorAware;
/** /**
@@ -27,20 +29,20 @@ import org.springframework.data.domain.AuditorAware;
*/ */
public class AuditorAwareImpl implements AuditorAware<AuditableUser> { public class AuditorAwareImpl implements AuditorAware<AuditableUser> {
private AuditableUser auditor; private Optional<AuditableUser> auditor = Optional.empty();
/** /**
* @param auditor the auditor to set * @param auditor the auditor to set
*/ */
public void setAuditor(AuditableUser auditor) { public void setAuditor(AuditableUser auditor) {
this.auditor = auditor; this.auditor = Optional.of(auditor);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.domain.AuditorAware#getCurrentAuditor() * @see org.springframework.data.domain.AuditorAware#getCurrentAuditor()
*/ */
public AuditableUser getCurrentAuditor() { public Optional<AuditableUser> getCurrentAuditor() {
return auditor; return auditor;
} }
} }

View File

@@ -15,7 +15,10 @@
*/ */
package example.springdata.jpa.basics; package example.springdata.jpa.basics;
import static org.junit.Assert.*; import static org.assertj.core.api.Assertions.*;
import example.springdata.jpa.simple.SimpleUserRepository;
import example.springdata.jpa.simple.User;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
@@ -26,9 +29,6 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; import org.springframework.data.jpa.repository.support.JpaRepositoryFactory;
import example.springdata.jpa.simple.SimpleUserRepository;
import example.springdata.jpa.simple.User;
/** /**
* Test case showing how to use the basic {@link GenericDaoFactory} * Test case showing how to use the basic {@link GenericDaoFactory}
* *
@@ -81,8 +81,8 @@ public class BasicFactorySetup {
@Test @Test
public void executingFinders() { public void executingFinders() {
assertEquals(user, userRepository.findByTheUsersName("username")); assertThat(userRepository.findByTheUsersName("username")).isEqualTo(user);
assertEquals(user, userRepository.findByLastname("lastname").get(0)); assertThat(userRepository.findByLastname("lastname")).first().isEqualTo(user);
assertEquals(user, userRepository.findByFirstname("firstname").get(0)); assertThat(userRepository.findByFirstname("firstname")).first().isEqualTo(user);
} }
} }

View File

@@ -19,7 +19,9 @@ ess or implied.
*/ */
package example.springdata.jpa.basics; package example.springdata.jpa.basics;
import static org.junit.Assert.*; import static org.assertj.core.api.Assertions.*;
import example.springdata.jpa.simple.User;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
@@ -31,8 +33,6 @@ import org.junit.Test;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import example.springdata.jpa.simple.User;
/** /**
* This unit tests shows plain usage of {@link SimpleJpaRepository}. * This unit tests shows plain usage of {@link SimpleJpaRepository}.
* *
@@ -41,8 +41,8 @@ import example.springdata.jpa.simple.User;
*/ */
public class BasicSample { public class BasicSample {
private CrudRepository<User, Long> userRepository; CrudRepository<User, Long> userRepository;
private EntityManager em; EntityManager em;
/** /**
* Sets up a {@link SimpleJpaRepository} instance. * Sets up a {@link SimpleJpaRepository} instance.
@@ -65,7 +65,7 @@ public class BasicSample {
/** /**
* Tests saving users. Don't mimic transactionality shown here. It seriously lacks resource cleanup in case of an * Tests saving users. Don't mimic transactionality shown here. It seriously lacks resource cleanup in case of an
* exception. Simplification serves descriptivness. * exception. Simplification serves descriptiveness.
*/ */
@Test @Test
public void savingUsers() { public void savingUsers() {
@@ -75,6 +75,6 @@ public class BasicSample {
user = userRepository.save(user); user = userRepository.save(user);
assertEquals(user, userRepository.findOne(user.getId())); assertThat(userRepository.findById(user.getId())).hasValue(user);
} }
} }

View File

@@ -15,15 +15,13 @@
*/ */
package example.springdata.jpa.caching; package example.springdata.jpa.caching;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
@@ -51,12 +49,10 @@ public abstract class CachingRepositoryTests {
dave = repository.save(dave); dave = repository.save(dave);
User result = repository.findByUsername("dmatthews"); assertThat(repository.findByUsername("dmatthews")).isEqualTo(dave);
assertThat(result, is(dave));
// Verify entity cached // Verify entity cached
Cache cache = cacheManager.getCache("byUsername"); Cache cache = cacheManager.getCache("byUsername");
ValueWrapper wrapper = cache.get("dmatthews"); assertThat(cache.get("dmatthews").get()).isEqualTo(dave);
assertThat(wrapper.get(), is((Object) dave));
} }
} }

View File

@@ -15,7 +15,7 @@
*/ */
package example.springdata.jpa.custom; package example.springdata.jpa.custom;
import static org.junit.Assert.*; import static org.assertj.core.api.Assertions.*;
import java.util.List; import java.util.List;
@@ -51,7 +51,7 @@ public class UserRepositoryCustomizationTests {
user = repository.save(user); user = repository.save(user);
assertEquals(user, repository.findOne(user.getId())); assertThat(repository.findById(user.getId())).hasValue(user);
} }
@Test @Test
@@ -65,11 +65,8 @@ public class UserRepositoryCustomizationTests {
List<User> users = repository.findByLastname("lastname"); List<User> users = repository.findByLastname("lastname");
assertNotNull(users); assertThat(users).contains(user);
assertTrue(users.contains(user)); assertThat(user).isEqualTo(repository.findByTheUsersName("foobar"));
User reference = repository.findByTheUsersName("foobar");
assertEquals(user, reference);
} }
/** /**
@@ -85,7 +82,6 @@ public class UserRepositoryCustomizationTests {
List<User> users = repository.myCustomBatchOperation(); List<User> users = repository.myCustomBatchOperation();
assertNotNull(users); assertThat(users).contains(user);
assertTrue(users.contains(user));
} }
} }

View File

@@ -15,8 +15,7 @@
*/ */
package example.springdata.jpa.customall; package example.springdata.jpa.customall;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -40,6 +39,6 @@ public class UserRepositoryCustomizationTests {
@Test @Test
public void invokesCustomMethod() { public void invokesCustomMethod() {
assertThat(repository.customMethod(), is(0L)); assertThat(repository.customMethod()).isEqualTo(0L);
} }
} }

View File

@@ -15,8 +15,7 @@
*/ */
package example.springdata.jpa.projections; package example.springdata.jpa.projections;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
@@ -64,37 +63,35 @@ public class CustomerRepositoryIntegrationTest {
@Test @Test
public void projectsEntityIntoInterface() { public void projectsEntityIntoInterface() {
Collection<CustomerProjection> result = customers.findAllProjectedBy(); assertThat(customers.findAllProjectedBy())//
.hasSize(2)//
assertThat(result, hasSize(2)); .first().satisfies(it -> assertThat(it.getFirstname()).isEqualTo("Dave"));
assertThat(result.iterator().next().getFirstname(), is("Dave"));
} }
@Test @Test
public void projectsMapIntoInterface() { public void projectsMapIntoInterface() {
Collection<CustomerProjection> result = customers.findsByProjectedColumns(); assertThat(customers.findsByProjectedColumns())//
.hasSize(2)//
.first().satisfies(it -> assertThat(it.getFirstname()).isEqualTo("Dave"));
assertThat(result, hasSize(2));
assertThat(result.iterator().next().getFirstname(), is("Dave"));
} }
@Test @Test
public void projectsToDto() { public void projectsToDto() {
Collection<CustomerDto> result = customers.findAllDtoedBy(); assertThat(customers.findAllDtoedBy())//
.hasSize(2)//
assertThat(result, hasSize(2)); .first().satisfies(it -> assertThat(it.getFirstname()).isEqualTo("Dave"));
assertThat(result.iterator().next().getFirstname(), is("Dave"));
} }
@Test @Test
public void projectsDynamically() { public void projectsDynamically() {
Collection<CustomerProjection> result = customers.findByFirstname("Dave", CustomerProjection.class); assertThat(customers.findByFirstname("Dave", CustomerProjection.class))//
.hasSize(1)//
assertThat(result, hasSize(1)); .first()//
assertThat(result.iterator().next().getFirstname(), is("Dave")); .satisfies(it -> assertThat(it.getFirstname()).isEqualTo("Dave"));
} }
@Test @Test
@@ -102,10 +99,11 @@ public class CustomerRepositoryIntegrationTest {
CustomerSummary result = customers.findProjectedById(dave.getId(), CustomerSummary.class); CustomerSummary result = customers.findProjectedById(dave.getId(), CustomerSummary.class);
assertThat(result.getFullName(), is("Dave Matthews")); assertThat(result.getFullName()).isEqualTo("Dave Matthews");
// Proxy backed by original instance as the projection uses dynamic elements // Proxy backed by original instance as the projection uses dynamic elements
assertThat(((TargetAware) result).getTarget(), is(instanceOf(Customer.class))); assertThat(result).isInstanceOfSatisfying(TargetAware.class,
it -> assertThat(it.getTarget()).isInstanceOf(Customer.class));
} }
@Test @Test
@@ -113,8 +111,9 @@ public class CustomerRepositoryIntegrationTest {
CustomerProjection projectedDave = customers.findProjectedById(dave.getId()); CustomerProjection projectedDave = customers.findProjectedById(dave.getId());
assertThat(projectedDave.getFirstname(), is("Dave")); assertThat(projectedDave.getFirstname()).isEqualTo("Dave");
assertThat(((TargetAware) projectedDave).getTarget(), is(instanceOf(Map.class))); assertThat(projectedDave).isInstanceOfSatisfying(TargetAware.class,
it -> assertThat(it.getTarget()).isInstanceOf(Map.class));
} }
@Test @Test
@@ -122,21 +121,21 @@ public class CustomerRepositoryIntegrationTest {
Collection<CustomerDto> result = customers.findDtoWithConstructorExpression("Dave"); Collection<CustomerDto> result = customers.findDtoWithConstructorExpression("Dave");
assertThat(result, hasSize(1)); assertThat(result).hasSize(1);
assertThat(result.iterator().next().getFirstname(), is("Dave")); assertThat(result.iterator().next().getFirstname()).isEqualTo("Dave");
} }
@Test @Test
public void supportsProjectionInCombinationWithPagination() { public void supportsProjectionInCombinationWithPagination() {
Page<CustomerProjection> page = customers Page<CustomerProjection> page = customers
.findPagedProjectedBy(new PageRequest(0, 1, new Sort(Direction.ASC, "lastname"))); .findPagedProjectedBy(PageRequest.of(0, 1, Sort.by(Direction.ASC, "lastname")));
assertThat(page.getContent().get(0).getFirstname(), is("Carter")); assertThat(page.getContent().get(0).getFirstname()).isEqualTo("Carter");
} }
@Test @Test
public void appliesProjectionToOptional() { public void appliesProjectionToOptional() {
assertThat(customers.findOptionalProjectionByLastname("Beauford").isPresent(), is(true)); assertThat(customers.findOptionalProjectionByLastname("Beauford")).isPresent();
} }
} }

View File

@@ -15,8 +15,9 @@
*/ */
package example.springdata.jpa.simple; package example.springdata.jpa.simple;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.assertThat;
import static org.springframework.data.domain.Sort.Direction.*; import static org.springframework.data.domain.Sort.Direction.*;
import java.util.ArrayList; import java.util.ArrayList;
@@ -64,7 +65,7 @@ public class SimpleUserRepositoryTests {
user = repository.save(user); user = repository.save(user);
assertThat(repository.findOne(user.getId()), is(user)); assertThat(repository.findById(user.getId())).hasValue(user);
} }
@Test @Test
@@ -72,10 +73,7 @@ public class SimpleUserRepositoryTests {
user = repository.save(user); user = repository.save(user);
List<User> users = repository.findByLastname("lastname"); assertThat(repository.findByLastname("lastname")).contains(user);
assertThat(users, is(notNullValue()));
assertThat(users.contains(user), is(true));
} }
@Test @Test
@@ -83,19 +81,17 @@ public class SimpleUserRepositoryTests {
user = repository.save(user); user = repository.save(user);
List<User> users = repository.findByFirstnameOrLastname("lastname"); assertThat(repository.findByFirstnameOrLastname("lastname")).contains(user);
assertThat(users.contains(user), is(true));
} }
@Test @Test
public void useOptionalAsReturnAndParameterType() { public void useOptionalAsReturnAndParameterType() {
assertThat(repository.findByUsername(Optional.of("foobar")), is(Optional.empty())); assertThat(repository.findByUsername(Optional.of("foobar"))).isEmpty();
repository.save(user); repository.save(user);
assertThat(repository.findByUsername(Optional.of("foobar")).isPresent(), is(true)); assertThat(repository.findByUsername(Optional.of("foobar"))).isPresent();
} }
@Test @Test
@@ -109,10 +105,10 @@ public class SimpleUserRepositoryTests {
User user3 = new User(); User user3 = new User();
user3.setLastname("no-positive-match"); user3.setLastname("no-positive-match");
repository.save(Arrays.asList(user, user2, user3)); repository.saveAll(Arrays.asList(user, user2, user3));
assertThat(repository.removeByLastname(user.getLastname()), is(2L)); assertThat(repository.removeByLastname(user.getLastname())).isEqualTo(2L);
assertThat(repository.exists(user3.getId()), is(true)); assertThat(repository.existsById(user3.getId())).isTrue();
} }
@Test @Test
@@ -132,11 +128,11 @@ public class SimpleUserRepositoryTests {
source.add(user); source.add(user);
} }
repository.save(source); repository.saveAll(source);
Slice<User> users = repository.findByLastnameOrderByUsernameAsc(this.user.getLastname(), new PageRequest(1, 5)); Slice<User> users = repository.findByLastnameOrderByUsernameAsc(this.user.getLastname(), PageRequest.of(1, 5));
assertThat(users, contains(source.subList(5, 10).toArray())); assertThat(users).containsAll(source.subList(5, 10));
} }
@Test @Test
@@ -152,7 +148,7 @@ public class SimpleUserRepositoryTests {
user2.setLastname("lastname-2"); user2.setLastname("lastname-2");
// we deliberatly save the items in reverse // we deliberatly save the items in reverse
repository.save(Arrays.asList(user2, user1, user0)); repository.saveAll(Arrays.asList(user2, user1, user0));
List<User> result = repository.findFirst2ByOrderByLastnameAsc(); List<User> result = repository.findFirst2ByOrderByLastnameAsc();
@@ -173,7 +169,7 @@ public class SimpleUserRepositoryTests {
user2.setLastname("lastname-2"); user2.setLastname("lastname-2");
// we deliberately save the items in reverse // we deliberately save the items in reverse
repository.save(Arrays.asList(user2, user1, user0)); repository.saveAll(Arrays.asList(user2, user1, user0));
List<User> resultAsc = repository.findTop2By(new Sort(ASC, "lastname")); List<User> resultAsc = repository.findTop2By(new Sort(ASC, "lastname"));
@@ -197,7 +193,7 @@ public class SimpleUserRepositoryTests {
User third = new User(); User third = new User();
repository.save(Arrays.asList(first, second, third)); repository.saveAll(Arrays.asList(first, second, third));
User reference = new User(); User reference = new User();
reference.setFirstname("firstname"); reference.setFirstname("firstname");

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-jpa-java8</artifactId> <artifactId>spring-data-jpa-java8</artifactId>

View File

@@ -39,7 +39,7 @@ public interface CustomerRepository extends Repository<Customer, Long> {
* @param id * @param id
* @return * @return
*/ */
Optional<Customer> findOne(Long id); Optional<Customer> findById(Long id);
/** /**
* Saves the given {@link Customer}. * Saves the given {@link Customer}.

View File

@@ -15,8 +15,7 @@
*/ */
package example.springdata.jpa.java8; package example.springdata.jpa.java8;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -54,8 +53,8 @@ public class Java8IntegrationTests {
Customer carter = repository.save(new Customer("Carter", "Beauford")); Customer carter = repository.save(new Customer("Carter", "Beauford"));
assertThat(repository.findOne(carter.id).isPresent(), is(true)); assertThat(repository.findById(carter.id)).isPresent();
assertThat(repository.findOne(carter.id + 1), is(Optional.<Customer> empty())); assertThat(repository.findById(carter.id + 1)).isEmpty();
} }
@Test @Test
@@ -63,8 +62,8 @@ public class Java8IntegrationTests {
Customer customer = repository.save(new Customer("Dave", "Matthews")); Customer customer = repository.save(new Customer("Dave", "Matthews"));
assertThat(customer.createdDate, is(notNullValue())); assertThat(customer.createdDate).isNotNull();
assertThat(customer.modifiedDate, is(notNullValue())); assertThat(customer.modifiedDate).isNotNull();
} }
@Test @Test
@@ -73,8 +72,7 @@ public class Java8IntegrationTests {
Customer customer = repository.save(new Customer("Dave", "Matthews")); Customer customer = repository.save(new Customer("Dave", "Matthews"));
Optional<Customer> result = repository.findByLastname(customer); Optional<Customer> result = repository.findByLastname(customer);
assertThat(result.isPresent(), is(true)); assertThat(result).hasValue(customer);
assertThat(result.get(), is(customer));
} }
/** /**
@@ -88,7 +86,7 @@ public class Java8IntegrationTests {
Customer customer2 = repository.save(new Customer("Customer2", "Bar")); Customer customer2 = repository.save(new Customer("Customer2", "Bar"));
try (Stream<Customer> stream = repository.streamAllCustomers()) { try (Stream<Customer> stream = repository.streamAllCustomers()) {
assertThat(stream.collect(Collectors.toList()), hasItems(customer1, customer2)); assertThat(stream.collect(Collectors.toList())).contains(customer1, customer2);
} }
} }
@@ -103,7 +101,7 @@ public class Java8IntegrationTests {
Customer customer2 = repository.save(new Customer("Customer2", "Bar")); Customer customer2 = repository.save(new Customer("Customer2", "Bar"));
try (Stream<Customer> stream = repository.findAllByLastnameIsNotNull()) { try (Stream<Customer> stream = repository.findAllByLastnameIsNotNull()) {
assertThat(stream.collect(Collectors.toList()), hasItems(customer1, customer2)); assertThat(stream.collect(Collectors.toList())).contains(customer1, customer2);
} }
} }
@@ -131,7 +129,7 @@ public class Java8IntegrationTests {
CompletableFuture<Void> future = repository.readAllBy().thenAccept(customers -> { CompletableFuture<Void> future = repository.readAllBy().thenAccept(customers -> {
assertThat(customers, hasSize(2)); assertThat(customers).hasSize(2);
customers.forEach(customer -> log.info(customer.toString())); customers.forEach(customer -> log.info(customer.toString()));
log.info("Completed!"); log.info("Completed!");
}); });

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-jpa-javaslang</artifactId> <artifactId>spring-data-jpa-javaslang</artifactId>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-jpa-jpa21</artifactId> <artifactId>spring-data-jpa-jpa21</artifactId>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-jpa-multiple-datasources</artifactId> <artifactId>spring-data-jpa-multiple-datasources</artifactId>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<name>Spring Data JPA - Examples</name> <name>Spring Data JPA - Examples</name>
@@ -23,7 +23,7 @@
<module>java8</module> <module>java8</module>
<module>javaslang</module> <module>javaslang</module>
<module>jpa21</module> <module>jpa21</module>
<module>security</module> <!--<module>security</module>-->
<module>multiple-datasources</module> <module>multiple-datasources</module>
<module>eclipselink</module> <module>eclipselink</module>
<module>query-by-example</module> <module>query-by-example</module>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-jpa-query-by-example</artifactId> <artifactId>spring-data-jpa-query-by-example</artifactId>

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-jpa-examples</artifactId> <artifactId>spring-data-jpa-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -15,23 +15,23 @@
*/ */
package example.springdata.jpa.showcase.snippets; package example.springdata.jpa.showcase.snippets;
import java.util.List;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;
import example.springdata.jpa.showcase.core.Account; import example.springdata.jpa.showcase.core.Account;
import example.springdata.jpa.showcase.core.Customer; import example.springdata.jpa.showcase.core.Customer;
import java.util.List;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;
/** /**
* Repository to manage {@link Account} instances. * Repository to manage {@link Account} instances.
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@NoRepositoryBean @NoRepositoryBean
public interface AccountRepository extends CrudRepository<Account, Long>, AccountRepositoryCustom, public interface AccountRepository
QueryDslPredicateExecutor<Account> { extends CrudRepository<Account, Long>, AccountRepositoryCustom, QuerydslPredicateExecutor<Account> {
/** /**
* Returns all accounts belonging to the given {@link Customer}. * Returns all accounts belonging to the given {@link Customer}.

View File

@@ -16,14 +16,17 @@
package example.springdata.jpa.showcase.snippets.test; package example.springdata.jpa.showcase.snippets.test;
import static example.springdata.jpa.showcase.snippets.AccountPredicates.*; import static example.springdata.jpa.showcase.snippets.AccountPredicates.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.assertThat;
import org.joda.time.LocalDate;
import example.springdata.jpa.showcase.core.Account; import example.springdata.jpa.showcase.core.Account;
import example.springdata.jpa.showcase.snippets.AccountRepository; import example.springdata.jpa.showcase.snippets.AccountRepository;
import java.util.Optional;
import org.joda.time.LocalDate;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@@ -39,12 +42,12 @@ public abstract class AccountRepositoryIntegrationTest {
public void findsExpiredAccounts() { public void findsExpiredAccounts() {
Account expired = accountRepository.findOne(1L); Optional<Account> expired = accountRepository.findById(1L);
Account valid = accountRepository.findOne(2L); Optional<Account> valid = accountRepository.findById(2L);
Iterable<Account> findAll = accountRepository.findAll(expiresBefore(new LocalDate(2011, 3, 1))); Iterable<Account> findAll = accountRepository.findAll(expiresBefore(new LocalDate(2011, 3, 1)));
assertThat(findAll, hasItem(expired)); assertThat(findAll).contains(expired.get());
assertThat(findAll, not(hasItem(valid))); assertThat(findAll).doesNotContain(valid.get());
} }
} }

View File

@@ -16,18 +16,18 @@
package example.springdata.jpa.showcase.snippets.test; package example.springdata.jpa.showcase.snippets.test;
import static example.springdata.jpa.showcase.snippets.CustomerSpecifications.*; import static example.springdata.jpa.showcase.snippets.CustomerSpecifications.*;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import static org.springframework.data.jpa.domain.Specifications.*; import static org.springframework.data.jpa.domain.Specifications.*;
import java.util.List;
import org.joda.time.LocalDate;
import org.springframework.data.jpa.domain.Specification;
import example.springdata.jpa.showcase.after.CustomerRepository; import example.springdata.jpa.showcase.after.CustomerRepository;
import example.springdata.jpa.showcase.core.Customer; import example.springdata.jpa.showcase.core.Customer;
import java.util.List;
import java.util.Optional;
import org.joda.time.LocalDate;
import org.springframework.data.jpa.domain.Specification;
/** /**
* Snippets to show the usage of {@link Specification}s. * Snippets to show the usage of {@link Specification}s.
* *
@@ -39,12 +39,12 @@ public class CustomerRepositoryIntegrationTest {
public void findsCustomersBySpecification() throws Exception { public void findsCustomersBySpecification() throws Exception {
Customer dave = repository.findOne(1L); Optional<Customer> dave = repository.findById(1L);
LocalDate expiryLimit = new LocalDate(2011, 3, 1); LocalDate expiryLimit = new LocalDate(2011, 3, 1);
List<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit))); List<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit)));
assertThat(result.size(), is(1)); assertThat(result).hasSize(1);
assertThat(result, hasItems(dave)); assertThat(dave).hasValueSatisfying(it -> assertThat(result).contains(it));
} }
} }

View File

@@ -15,18 +15,19 @@
*/ */
package example.springdata.jpa.showcase.after; package example.springdata.jpa.showcase.after;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import example.springdata.jpa.showcase.AbstractShowcaseTest; import example.springdata.jpa.showcase.AbstractShowcaseTest;
import example.springdata.jpa.showcase.core.Account; import example.springdata.jpa.showcase.core.Account;
import example.springdata.jpa.showcase.core.Customer; import example.springdata.jpa.showcase.core.Customer;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* Integration tests for Spring Data JPA {@link AccountRepository}. * Integration tests for Spring Data JPA {@link AccountRepository}.
* *
@@ -41,16 +42,17 @@ public class AccountRepositoryIntegrationTest extends AbstractShowcaseTest {
public void savesAccount() { public void savesAccount() {
Account account = accountRepository.save(new Account()); Account account = accountRepository.save(new Account());
assertThat(account.getId(), is(notNullValue()));
assertThat(account.getId()).isNotNull();
} }
@Test @Test
public void findsCustomersAccounts() { public void findsCustomersAccounts() {
Customer customer = customerRepository.findOne(1L); Optional<Customer> customer = customerRepository.findById(1L);
List<Account> accounts = accountRepository.findByCustomer(customer); List<Account> accounts = customer.map(accountRepository::findByCustomer).orElse(Collections.emptyList());
assertFalse(accounts.isEmpty()); assertThat(accounts).isNotEmpty();
assertThat(accounts.get(0).getCustomer(), is(customer)); assertThat(customer).hasValueSatisfying(it -> assertThat(accounts.get(0).getCustomer()).isEqualTo(it));
} }
} }

View File

@@ -16,11 +16,14 @@
package example.springdata.jpa.showcase.after; package example.springdata.jpa.showcase.after;
import static example.springdata.jpa.showcase.snippets.CustomerSpecifications.*; import static example.springdata.jpa.showcase.snippets.CustomerSpecifications.*;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import static org.springframework.data.jpa.domain.Specifications.*; import static org.springframework.data.jpa.domain.Specifications.*;
import example.springdata.jpa.showcase.AbstractShowcaseTest;
import example.springdata.jpa.showcase.core.Customer;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.junit.Test; import org.junit.Test;
@@ -28,9 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import example.springdata.jpa.showcase.AbstractShowcaseTest;
import example.springdata.jpa.showcase.core.Customer;
/** /**
* Integration tests for Spring Data JPA {@link CustomerRepository}. * Integration tests for Spring Data JPA {@link CustomerRepository}.
* *
@@ -42,40 +42,36 @@ public class CustomerRepositoryIntegrationTest extends AbstractShowcaseTest {
@Test @Test
public void findsAllCustomers() throws Exception { public void findsAllCustomers() throws Exception {
assertThat(repository.findAll()).isNotEmpty();
Iterable<Customer> result = repository.findAll();
assertThat(result, is(notNullValue()));
assertTrue(result.iterator().hasNext());
} }
@Test @Test
public void findsFirstPageOfMatthews() throws Exception { public void findsFirstPageOfMatthews() throws Exception {
Page<Customer> customers = repository.findByLastname("Matthews", new PageRequest(0, 2)); Page<Customer> customers = repository.findByLastname("Matthews", PageRequest.of(0, 2));
assertThat(customers.getContent().size(), is(2)); assertThat(customers.getContent()).hasSize(2);
assertFalse(customers.hasPrevious()); assertThat(customers.hasPrevious()).isFalse();
} }
@Test @Test
public void findsCustomerById() throws Exception { public void findsCustomerById() throws Exception {
Customer customer = repository.findOne(2L); assertThat(repository.findById(2L)).hasValueSatisfying(it -> {
assertThat(it.getFirstname()).isEqualTo("Carter");
assertThat(customer.getFirstname(), is("Carter")); assertThat(it.getLastname()).isEqualTo("Beauford");
assertThat(customer.getLastname(), is("Beauford")); });
} }
@Test @Test
public void findsCustomersBySpecification() throws Exception { public void findsCustomersBySpecification() throws Exception {
Customer dave = repository.findOne(1L); Optional<Customer> dave = repository.findById(1L);
LocalDate expiryLimit = new LocalDate(2011, 3, 1); LocalDate expiryLimit = new LocalDate(2011, 3, 1);
List<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit))); List<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit)));
assertThat(result.size(), is(1)); assertThat(result).hasSize(1);
assertThat(result, hasItems(dave)); assertThat(dave).hasValueSatisfying(it -> assertThat(result).contains(it));
} }
} }

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-ldap-examples</artifactId> <artifactId>spring-data-ldap-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -18,6 +18,7 @@ package example.springdata.ldap;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.naming.InvalidNameException; import javax.naming.InvalidNameException;
import javax.naming.ldap.LdapName; import javax.naming.ldap.LdapName;
@@ -47,12 +48,13 @@ public class PersonRepositoryIntegrationTests {
@Test @Test
public void findOneByName() throws InvalidNameException { public void findOneByName() throws InvalidNameException {
Person person = personRepository.findOne(new LdapName("uid=bob,ou=people,dc=springframework,dc=org")); Optional<Person> person = personRepository.findById(new LdapName("uid=bob,ou=people,dc=springframework,dc=org"));
assertThat(person).isNotNull(); assertThat(person).hasValueSatisfying(it -> {
assertThat(person.getFullName()).isEqualTo("Bob Hamilton"); assertThat(it.getFullName()).isEqualTo("Bob Hamilton");
assertThat(person.getLastname()).isEqualTo("Hamilton"); assertThat(it.getLastname()).isEqualTo("Hamilton");
assertThat(person.getUid()).isEqualTo("bob"); assertThat(it.getUid()).isEqualTo("bob");
});
} }
/** /**

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -15,8 +15,7 @@
*/ */
package example.springdata.map; package example.springdata.map;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.List; import java.util.List;
@@ -48,7 +47,7 @@ public class PersonRepositoryIntegrationTest {
Person person = repository.save(new Person("Dave", "Matthews", 47)); Person person = repository.save(new Person("Dave", "Matthews", 47));
assertThat(repository.findOne(person.getId()), is(person)); assertThat(repository.findById(person.getId())).hasValue(person);
} }
@Test @Test
@@ -59,7 +58,7 @@ public class PersonRepositoryIntegrationTest {
List<Person> result = repository.findByAgeGreaterThan(18); List<Person> result = repository.findByAgeGreaterThan(18);
assertThat(result, hasItem(dave)); assertThat(result).contains(dave);
assertThat(result, not(hasItem(oliver))); assertThat(result).doesNotContain(oliver);
} }
} }

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
</project> </project>

View File

@@ -26,6 +26,7 @@ import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import org.assertj.core.util.Files; import org.assertj.core.util.Files;
import org.bson.Document;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -44,7 +45,6 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.mongodb.DBObject;
import com.mongodb.util.JSON; import com.mongodb.util.JSON;
/** /**
@@ -240,9 +240,9 @@ public class SpringBooksIntegrationTests {
.andOutput("author").push().as("authors") // .andOutput("author").push().as("authors") //
).as("authors")); ).as("authors"));
AggregationResults<DBObject> result = operations.aggregate(aggregation, "books", DBObject.class); AggregationResults<Document> result = operations.aggregate(aggregation, "books", Document.class);
DBObject uniqueMappedResult = result.getUniqueMappedResult(); Document uniqueMappedResult = result.getUniqueMappedResult();
assertThat((List<Object>) uniqueMappedResult.get("prices")).hasSize(3); assertThat((List<Object>) uniqueMappedResult.get("prices")).hasSize(3);
assertThat((List<Object>) uniqueMappedResult.get("authors")).hasSize(8); assertThat((List<Object>) uniqueMappedResult.get("authors")).hasSize(8);

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<build> <build>

View File

@@ -18,11 +18,11 @@ package example.springdata.mongodb.advanced;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.MongoOperations;
import com.mongodb.BasicDBObject;
import com.mongodb.MongoClient; import com.mongodb.MongoClient;
/** /**
@@ -62,6 +62,6 @@ class ApplicationConfiguration {
} }
private void setProfilingLevel(int level) { private void setProfilingLevel(int level) {
operations.executeCommand(new BasicDBObject("profile", level)); operations.executeCommand(new Document("profile", level));
} }
} }

View File

@@ -15,11 +15,11 @@
*/ */
package example.springdata.mongodb.advanced; package example.springdata.mongodb.advanced;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import example.springdata.mongodb.customer.Customer; import example.springdata.mongodb.customer.Customer;
import org.bson.Document;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -31,8 +31,7 @@ import org.springframework.data.mongodb.core.query.Meta;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor; import com.mongodb.client.FindIterable;
import com.mongodb.DBObject;
/** /**
* @author Christoph Strobl * @author Christoph Strobl
@@ -70,17 +69,15 @@ public class AdvancedIntegrationTests {
repository.findByFirstname(dave.getFirstname()); repository.findByFirstname(dave.getFirstname());
// execute another finder without meta attributes that should not be picked up // execute another finder without meta attributes that should not be picked up
repository.findByLastname(dave.getLastname(), new Sort("firstname")); repository.findByLastname(dave.getLastname(), Sort.by("firstname"));
DBCursor cursor = operations.getCollection(ApplicationConfiguration.SYSTEM_PROFILE_DB) FindIterable<Document> cursor = operations.getCollection(ApplicationConfiguration.SYSTEM_PROFILE_DB)
.find(new BasicDBObject("query.$comment", AdvancedRepository.META_COMMENT)); .find(new BasicDBObject("query.$comment", AdvancedRepository.META_COMMENT));
while (cursor.hasNext()) { for (Document document : cursor) {
DBObject dbo = cursor.next(); Document query = (Document) document.get("query");
DBObject query = (DBObject) dbo.get("query"); assertThat(query).containsKey("foo");
assertThat(query.containsField("$comment"), is(true));
} }
} }
} }

View File

@@ -15,15 +15,15 @@
*/ */
package example.springdata.mongodb.advanced; package example.springdata.mongodb.advanced;
import static org.hamcrest.core.Is.*; import static org.assertj.core.api.Assertions.*;
import static org.hamcrest.core.IsNull.*;
import static org.junit.Assert.*;
import example.springdata.mongodb.customer.Customer; import example.springdata.mongodb.customer.Customer;
import java.util.Map; import java.util.Map;
import org.bson.Document;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -33,9 +33,6 @@ import org.springframework.data.mongodb.core.script.ExecutableMongoScript;
import org.springframework.data.mongodb.core.script.NamedMongoScript; import org.springframework.data.mongodb.core.script.NamedMongoScript;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
/** /**
* @author Christoph Strobl * @author Christoph Strobl
* @author Oliver Gierke * @author Oliver Gierke
@@ -55,7 +52,7 @@ public class ServersideScriptTests {
} }
// just make sure we remove everything properly // just make sure we remove everything properly
operations.getCollection("system.js").remove(new BasicDBObject()); operations.getCollection("system.js").deleteMany(new Document());
repository.deleteAll(); repository.deleteAll();
} }
@@ -68,8 +65,7 @@ public class ServersideScriptTests {
operations.scriptOps() operations.scriptOps()
.register(new NamedMongoScript("echoScript", new ExecutableMongoScript("function(x) { return x; }"))); .register(new NamedMongoScript("echoScript", new ExecutableMongoScript("function(x) { return x; }")));
Object o = operations.scriptOps().call("echoScript", "Hello echo...!"); assertThat(operations.scriptOps().call("echoScript", "Hello echo...!")).isEqualTo("Hello echo...!");
assertThat(o, is((Object) "Hello echo...!"));
} }
/** /**
@@ -77,35 +73,37 @@ public class ServersideScriptTests {
* {@link Map#putIfAbsent(Object, Object)} * {@link Map#putIfAbsent(Object, Object)}
*/ */
@Test @Test
@Ignore
public void complexScriptExecutionSimulatingPutIfAbsent() { public void complexScriptExecutionSimulatingPutIfAbsent() {
Customer ned = new Customer("Ned", "Stark"); Customer ned = new Customer("Ned", "Stark");
ned.setId("ned-stark"); ned.setId("ned-stark");
// #1: on first insert null has to be returned // #1: on first insert null has to be returned
assertThat(operations.scriptOps().execute(createExecutablePutIfAbsentScript(ned)), nullValue()); assertThat(operations.scriptOps().execute(createExecutablePutIfAbsentScript(ned))).isNotNull();
// #2: change the firstname and put the object again, we expect a return value. // #2: change the firstname and put the object again, we expect a return value.
ned.setFirstname("Eddard"); ned.setFirstname("Eddard");
assertThat(operations.scriptOps().execute(createExecutablePutIfAbsentScript(ned)), notNullValue()); assertThat(operations.scriptOps().execute(createExecutablePutIfAbsentScript(ned))).isNotNull();
// #3: make sure the entity has not been altered by #2 // #3: make sure the entity has not been altered by #2
assertThat(repository.findOne(ned.getId()).getFirstname(), is("Ned")); assertThat(repository.findById(ned.getId()))
assertThat(repository.count(), is(1L)); .hasValueSatisfying(it -> assertThat(it.getFirstname()).isEqualTo("Ned"));
assertThat(repository.count()).isEqualTo(1L);
} }
private ExecutableMongoScript createExecutablePutIfAbsentScript(Customer customer) { private ExecutableMongoScript createExecutablePutIfAbsentScript(Customer customer) {
String collectionName = operations.getCollectionName(Customer.class); String collectionName = operations.getCollectionName(Customer.class);
Object id = operations.getConverter().getMappingContext().getPersistentEntity(Customer.class) Object id = operations.getConverter().getMappingContext().getRequiredPersistentEntity(Customer.class)
.getIdentifierAccessor(customer).getIdentifier(); .getIdentifierAccessor(customer).getIdentifier();
DBObject dbo = new BasicDBObject(); Document document = new Document();
operations.getConverter().write(customer, dbo); operations.getConverter().write(customer, document);
String scriptString = String.format( String scriptString = String.format(
"object = db.%1$s.findOne({\"_id\": \"%2$s\"}); if (object == null) { db.%1s.insert(%3$s); return null; } else { return object; }", "object = db.%1$s.findOne({\"_id\": \"%2$s\"}); if (object == null) { db.%1s.insert(%3$s); return null; } else { return object; }",
collectionName, id, dbo); collectionName, id, document);
return new ExecutableMongoScript(scriptString); return new ExecutableMongoScript(scriptString);
} }

View File

@@ -113,7 +113,7 @@ public class CustomerRepositoryIntegrationTest {
public void supportsProjectionInCombinationWithPagination() { public void supportsProjectionInCombinationWithPagination() {
Page<CustomerProjection> page = customers Page<CustomerProjection> page = customers
.findPagedProjectedBy(new PageRequest(0, 1, new Sort(Direction.ASC, "lastname"))); .findPagedProjectedBy(PageRequest.of(0, 1, Sort.by(Direction.ASC, "lastname")));
assertThat(page.getContent().get(0).getFirstname(), is("Carter")); assertThat(page.getContent().get(0).getFirstname(), is("Carter"));
} }

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-mongodb-geojson</artifactId> <artifactId>spring-data-mongodb-geojson</artifactId>

View File

@@ -15,6 +15,7 @@
*/ */
package example.springdata.mongodb.geojson; package example.springdata.mongodb.geojson;
import org.bson.Document;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -29,9 +30,6 @@ import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
/** /**
* Integration tests for {@link StoreRepository}. * Integration tests for {@link StoreRepository}.
* *
@@ -116,12 +114,12 @@ public class StoreRepositoryTests {
@Test @Test
public void findStoresThatIntersectGivenPolygon() { public void findStoresThatIntersectGivenPolygon() {
DBObject geoJsonDbo = new BasicDBObject(); Document geoJsonDbo = new Document();
operations.getConverter().write(GEO_JSON_POLYGON, geoJsonDbo); operations.getConverter().write(GEO_JSON_POLYGON, geoJsonDbo);
BasicQuery bq = new BasicQuery( BasicQuery bq = new BasicQuery(
new BasicDBObject("location", new BasicDBObject("$geoIntersects", new BasicDBObject("$geometry", geoJsonDbo)))); new Document("location", new Document("$geoIntersects", new Document("$geometry", geoJsonDbo))));
operations.find(bq, Store.class).forEach(System.out::println); operations.find(bq, Store.class).forEach(System.out::println);
} }

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-mongodb-java8</artifactId> <artifactId>spring-data-mongodb-java8</artifactId>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<name>Spring Data MongoDB - Examples</name> <name>Spring Data MongoDB - Examples</name>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-mongodb-query-by-example</artifactId> <artifactId>spring-data-mongodb-query-by-example</artifactId>

View File

@@ -5,54 +5,31 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-mongodb-reactive</artifactId> <artifactId>spring-data-mongodb-reactive</artifactId>
<name>Spring Data MongoDB - Reactive features</name> <name>Spring Data MongoDB - Reactive features</name>
<properties> <properties>
<spring-data-releasetrain.version>Kay-M1</spring-data-releasetrain.version>
<spring.version>5.0.0.M3</spring.version>
<reactor.version>3.0.3.RELEASE</reactor.version>
<rxjava.version>1.2.1</rxjava.version>
<rxjava-reactive-streams.version>1.2.0</rxjava-reactive-streams.version> <rxjava-reactive-streams.version>1.2.0</rxjava-reactive-streams.version>
<mongodb-driver-reactivestreams.version>1.3.0</mongodb-driver-reactivestreams.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-data-commons</artifactId> <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-reactivestreams</artifactId>
<version>${mongodb-driver-reactivestreams.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.reactivex</groupId> <groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId> <artifactId>rxjava</artifactId>
<version>${rxjava.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.reactivex</groupId> <groupId>io.reactivex</groupId>
<artifactId>rxjava-reactive-streams</artifactId> <artifactId>rxjava-reactive-streams</artifactId>
<version>${rxjava-reactive-streams.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -18,8 +18,8 @@ package example.springdata.mongodb.people;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import org.springframework.data.mongodb.repository.InfiniteStream;
import org.springframework.data.mongodb.repository.Query; import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.Tailable;
import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.data.repository.reactive.ReactiveCrudRepository;
/** /**
@@ -70,6 +70,6 @@ public interface ReactivePersonRepository extends ReactiveCrudRepository<Person,
* *
* @return * @return
*/ */
@InfiniteStream @Tailable
Flux<Person> findWithTailableCursorBy(); Flux<Person> findWithTailableCursorBy();
} }

View File

@@ -18,8 +18,8 @@ package example.springdata.mongodb.people;
import rx.Observable; import rx.Observable;
import rx.Single; import rx.Single;
import org.springframework.data.mongodb.repository.InfiniteStream;
import org.springframework.data.mongodb.repository.Query; import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.Tailable;
import org.springframework.data.repository.reactive.RxJava1CrudRepository; import org.springframework.data.repository.reactive.RxJava1CrudRepository;
/** /**
@@ -70,6 +70,6 @@ public interface RxJava1PersonRepository extends RxJava1CrudRepository<Person, S
* *
* @return * @return
*/ */
@InfiniteStream @Tailable
Observable<Person> findWithTailableCursorBy(); Observable<Person> findWithTailableCursorBy();
} }

View File

@@ -78,7 +78,7 @@ public class ReactiveMongoTemplateIntegrationTest {
.last() // .last() //
.flatMap(v -> template.count(new Query(), Person.class)) // .flatMap(v -> template.count(new Query(), Person.class)) //
.doOnNext(System.out::println) // .doOnNext(System.out::println) //
.doOnComplete(countDownLatch::countDown) // .doOnSuccess(it -> countDownLatch.countDown()) //
.doOnError(throwable -> countDownLatch.countDown()) // .doOnError(throwable -> countDownLatch.countDown()) //
.subscribe(); .subscribe();

View File

@@ -17,7 +17,7 @@ package example.springdata.mongodb.people;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import reactor.core.Cancellation; import reactor.core.Disposable;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@@ -55,7 +55,7 @@ public class ReactivePersonRepositoryIntegrationTest {
.block(); .block();
repository repository
.save(Flux.just(new Person("Walter", "White", 50), // .saveAll(Flux.just(new Person("Walter", "White", 50), //
new Person("Skyler", "White", 45), // new Person("Skyler", "White", 45), //
new Person("Saul", "Goodman", 42), // new Person("Saul", "Goodman", 42), //
new Person("Jesse", "Pinkman", 27))) // new Person("Jesse", "Pinkman", 27))) //
@@ -74,12 +74,12 @@ public class ReactivePersonRepositoryIntegrationTest {
repository.count() // repository.count() //
.doOnNext(System.out::println) // .doOnNext(System.out::println) //
.thenMany(repository.save(Flux.just(new Person("Hank", "Schrader", 43), // .thenMany(repository.saveAll(Flux.just(new Person("Hank", "Schrader", 43), //
new Person("Mike", "Ehrmantraut", 62)))) // new Person("Mike", "Ehrmantraut", 62)))) //
.last() // .last() //
.flatMap(v -> repository.count()) // .flatMap(v -> repository.count()) //
.doOnNext(System.out::println) // .doOnNext(System.out::println) //
.doOnComplete(countDownLatch::countDown) // .doOnSuccess(it -> countDownLatch.countDown()) //
.doOnError(throwable -> countDownLatch.countDown()) // .doOnError(throwable -> countDownLatch.countDown()) //
.subscribe(); .subscribe();
@@ -109,7 +109,7 @@ public class ReactivePersonRepositoryIntegrationTest {
@Test @Test
public void shouldStreamDataWithTailableCursor() throws Exception { public void shouldStreamDataWithTailableCursor() throws Exception {
Cancellation cancellation = repository.findWithTailableCursorBy() // Disposable disposable = repository.findWithTailableCursorBy() //
.doOnNext(System.out::println) // .doOnNext(System.out::println) //
.doOnComplete(() -> System.out.println("Complete")) // .doOnComplete(() -> System.out.println("Complete")) //
.doOnTerminate(() -> System.out.println("Terminated")) // .doOnTerminate(() -> System.out.println("Terminated")) //
@@ -123,7 +123,7 @@ public class ReactivePersonRepositoryIntegrationTest {
repository.save(new Person("Mike", "Ehrmantraut", 62)).subscribe(); repository.save(new Person("Mike", "Ehrmantraut", 62)).subscribe();
Thread.sleep(100); Thread.sleep(100);
cancellation.dispose(); disposable.dispose();
repository.save(new Person("Gus", "Fring", 53)).subscribe(); repository.save(new Person("Gus", "Fring", 53)).subscribe();
Thread.sleep(100); Thread.sleep(100);

View File

@@ -59,7 +59,7 @@ public class RxJava1PersonRepositoryIntegrationTest {
.block(); .block();
repository repository
.save(Observable.just(new Person("Walter", "White", 50), // .saveAll(Observable.just(new Person("Walter", "White", 50), //
new Person("Skyler", "White", 45), // new Person("Skyler", "White", 45), //
new Person("Saul", "Goodman", 42), // new Person("Saul", "Goodman", 42), //
new Person("Jesse", "Pinkman", 27))) // new Person("Jesse", "Pinkman", 27))) //
@@ -75,11 +75,13 @@ public class RxJava1PersonRepositoryIntegrationTest {
CountDownLatch countDownLatch = new CountDownLatch(1); CountDownLatch countDownLatch = new CountDownLatch(1);
Observable<Person> people = Observable.just(new Person("Hank", "Schrader", 43), //
new Person("Mike", "Ehrmantraut", 62));
repository.count() // repository.count() //
.doOnSuccess(System.out::println) // .doOnSuccess(System.out::println) //
.toObservable() // .toObservable() //
.switchMap(count -> repository.save(Observable.just(new Person("Hank", "Schrader", 43), // .switchMap(count -> repository.saveAll(people)) //
new Person("Mike", "Ehrmantraut", 62)))) //
.last() // .last() //
.toSingle() // .toSingle() //
.flatMap(v -> repository.count()) // .flatMap(v -> repository.count()) //

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-mongodb-security</artifactId> <artifactId>spring-data-mongodb-security</artifactId>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-mongodb-examples</artifactId> <artifactId>spring-data-mongodb-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-neo4j-examples</artifactId> <artifactId>spring-data-neo4j-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -15,11 +15,11 @@
*/ */
package example.springdata.neo4j; package example.springdata.neo4j;
import org.springframework.data.neo4j.repository.GraphRepository; import org.springframework.data.neo4j.repository.Neo4jRepository;
/** /**
* {@link GraphRepository} for {@link Actor}s. * {@link GraphRepository} for {@link Actor}s.
* *
* @author Luanne Misquitta * @author Luanne Misquitta
*/ */
public interface ActorRepository extends GraphRepository<Actor> {} public interface ActorRepository extends Neo4jRepository<Actor, Long> {}

View File

@@ -15,8 +15,7 @@
*/ */
package example.springdata.neo4j; package example.springdata.neo4j;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -55,14 +54,10 @@ public class ActorRepositoryIntegrationTest {
actorRepository.save(daniel); // saves the actor and the movie actorRepository.save(daniel); // saves the actor and the movie
Actor actor = actorRepository.findOne(daniel.getId()); assertThat(actorRepository.findById(daniel.getId())).hasValueSatisfying(actor -> {
assertThat(actor.getName()).isEqualTo(daniel.getName());
assertThat(actor, is(notNullValue())); assertThat(actor.getRoles()).hasSize(1).first()
assertThat(actor.getName(), is(daniel.getName())); .satisfies(role -> assertThat(role.getRole()).isEqualTo("Harry Potter"));
assertThat(actor.getRoles(), hasSize(1)); });
Role role = actor.getRoles().iterator().next();
assertThat(role.getRole(), is("Harry Potter"));
} }
} }

View File

@@ -12,7 +12,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -4,7 +4,7 @@
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Spring Data - Examples</name> <name>Spring Data - Examples</name>
@@ -12,12 +12,12 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<modules> <modules>
<module>bom</module> <module>bom</module>
<module>cassandra</module> <!--<module>cassandra</module>-->
<module>elasticsearch</module> <module>elasticsearch</module>
<module>jpa</module> <module>jpa</module>
<module>ldap</module> <module>ldap</module>
@@ -27,7 +27,7 @@
<module>neo4j</module> <module>neo4j</module>
<module>rest</module> <module>rest</module>
<module>redis</module> <module>redis</module>
<module>solr</module> <!--<module>solr</module>-->
<module>web</module> <module>web</module>
</modules> </modules>
@@ -35,6 +35,7 @@
<apt.version>1.1.3</apt.version> <apt.version>1.1.3</apt.version>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<spring-data-releasetrain.version>Kay-RELEASE</spring-data-releasetrain.version>
</properties> </properties>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-redis-examples</artifactId> <artifactId>spring-data-redis-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-redis-examples</artifactId> <artifactId>spring-data-redis-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@@ -18,7 +18,7 @@
<modules> <modules>
<module>cluster</module> <module>cluster</module>
<module>example</module> <module>example</module>
<module>reactive</module> <!--<module>reactive</module>-->
<module>repositories</module> <module>repositories</module>
<module>sentinel</module> <module>sentinel</module>
<module>util</module> <module>util</module>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-redis-examples</artifactId> <artifactId>spring-data-redis-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -15,8 +15,10 @@
*/ */
package example.springdata.redis.repositories; package example.springdata.redis.repositories;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import example.springdata.redis.test.util.EmbeddedRedisServer; import example.springdata.redis.test.util.EmbeddedRedisServer;
import example.springdata.redis.test.util.RequiresRedisServer; import example.springdata.redis.test.util.RequiresRedisServer;
@@ -234,8 +236,9 @@ public class PersonRepositoryTests<K, V> {
repository.save(eddard); repository.save(eddard);
Person laoded = repository.findOne(eddard.getId()); assertThat(repository.findById(eddard.getId())).hasValueSatisfying(it -> {
assertThat(laoded.getChildren(), hasItems(jon, robb, sansa, arya, bran, rickon)); assertThat(it.getChildren()).contains(jon, robb, sansa, arya, bran, rickon);
});
/* /*
* Deceased: * Deceased:
@@ -243,14 +246,15 @@ public class PersonRepositoryTests<K, V> {
* - Robb was killed by Roose Bolton during the Red Wedding. * - Robb was killed by Roose Bolton during the Red Wedding.
* - Jon was stabbed by brothers or the Night's Watch. * - Jon was stabbed by brothers or the Night's Watch.
*/ */
repository.delete(Arrays.asList(robb, jon)); repository.deleteAll(Arrays.asList(robb, jon));
laoded = repository.findOne(eddard.getId()); assertThat(repository.findById(eddard.getId())).hasValueSatisfying(it -> {
assertThat(laoded.getChildren(), hasItems(sansa, arya, bran, rickon)); assertThat(it.getChildren()).contains(sansa, arya, bran, rickon);
assertThat(laoded.getChildren(), not(hasItems(robb, jon))); assertThat(it.getChildren()).doesNotContain(robb, jon);
});
} }
private void flushTestUsers() { private void flushTestUsers() {
repository.save(Arrays.asList(eddard, robb, sansa, arya, bran, rickon, jon)); repository.saveAll(Arrays.asList(eddard, robb, sansa, arya, bran, rickon, jon));
} }
} }

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-redis-examples</artifactId> <artifactId>spring-data-redis-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-redis-examples</artifactId> <artifactId>spring-data-redis-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId> <artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId> <artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<name>Spring Data REST - Examples</name> <name>Spring Data REST - Examples</name>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId> <artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId> <artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>

View File

@@ -38,9 +38,9 @@ public interface ItemRepository extends CrudRepository<Item, Long> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#delete(java.io.Serializable) * @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.Object)
*/ */
@Override @Override
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
void delete(Long aLong); void deleteById(Long aLong);
} }

View File

@@ -62,7 +62,7 @@ public class MethodLevelSecurityTests {
} }
try { try {
itemRepository.delete(1L); itemRepository.deleteById(1L);
fail("Expected a security error"); fail("Expected a security error");
} catch (AuthenticationCredentialsNotFoundException e) { } catch (AuthenticationCredentialsNotFoundException e) {
// expected // expected
@@ -83,7 +83,7 @@ public class MethodLevelSecurityTests {
// expected // expected
} }
try { try {
itemRepository.delete(1L); itemRepository.deleteById(1L);
fail("Expected a security error"); fail("Expected a security error");
} catch (AccessDeniedException e) { } catch (AccessDeniedException e) {
// expected // expected
@@ -96,7 +96,9 @@ public class MethodLevelSecurityTests {
SecurityUtils.runAs("system", "system", "ROLE_USER", "ROLE_ADMIN"); SecurityUtils.runAs("system", "system", "ROLE_USER", "ROLE_ADMIN");
itemRepository.findAll(); itemRepository.findAll();
itemRepository.save(new Item("MacBook Pro"));
itemRepository.delete(1L); Item item = itemRepository.save(new Item("MacBook Pro"));
itemRepository.deleteById(item.getId());
} }
} }

View File

@@ -18,7 +18,6 @@ package example.springdata.rest.security;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*; import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
@@ -70,8 +69,7 @@ public class UrlLevelSecurityTests {
mvc.perform(get("/").// mvc.perform(get("/").//
accept(MediaTypes.HAL_JSON)).// accept(MediaTypes.HAL_JSON)).//
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).// andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
andExpect(status().isOk()).// andExpect(status().isOk());
andDo(print());
} }
@Test @Test
@@ -80,8 +78,7 @@ public class UrlLevelSecurityTests {
mvc.perform(post("/employees").// mvc.perform(post("/employees").//
content(PAYLOAD).// content(PAYLOAD).//
accept(MediaTypes.HAL_JSON)).// accept(MediaTypes.HAL_JSON)).//
andExpect(status().isUnauthorized()).// andExpect(status().isUnauthorized());
andDo(print());
} }
@Test @Test
@@ -94,13 +91,11 @@ public class UrlLevelSecurityTests {
mvc.perform(get("/employees").// mvc.perform(get("/employees").//
headers(headers)).// headers(headers)).//
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).// andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
andExpect(status().isOk()).// andExpect(status().isOk());
andDo(print());
mvc.perform(post("/employees").// mvc.perform(post("/employees").//
headers(headers)).// headers(headers)).//
andExpect(status().isForbidden()).// andExpect(status().isForbidden());
andDo(print());
} }
@Test @Test
@@ -113,8 +108,7 @@ public class UrlLevelSecurityTests {
mvc.perform(get("/employees").// mvc.perform(get("/employees").//
headers(headers)).// headers(headers)).//
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).// andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
andExpect(status().isOk()).// andExpect(status().isOk());
andDo(print());
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
@@ -124,7 +118,6 @@ public class UrlLevelSecurityTests {
headers(headers)) headers(headers))
.// .//
andExpect(status().isCreated()).// andExpect(status().isCreated()).//
andDo(print()).//
andReturn().getResponse().getHeader(HttpHeaders.LOCATION); andReturn().getResponse().getHeader(HttpHeaders.LOCATION);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId> <artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>
@@ -28,7 +28,6 @@
<dependency> <dependency>
<groupId>com.querydsl</groupId> <groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId> <artifactId>querydsl-mongodb</artifactId>
<version>${querydsl.version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.mongodb</groupId> <groupId>org.mongodb</groupId>
@@ -120,7 +119,7 @@
<goal>process</goal> <goal>process</goal>
</goals> </goals>
<configuration> <configuration>
<outputDirectory>target/generated-sources/annotations</outputDirectory> <outputDirectory>target/generated-sources/queries</outputDirectory>
<processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor> <processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
<logOnlyOnError>true</logOnlyOnError> <logOnlyOnError>true</logOnlyOnError>
</configuration> </configuration>

View File

@@ -51,7 +51,7 @@ public class StoreInitializer {
List<Store> stores = readStores(); List<Store> stores = readStores();
log.info("Importing {} stores into MongoDB…", stores.size()); log.info("Importing {} stores into MongoDB…", stores.size());
repository.save(stores); repository.saveAll(stores);
log.info("Successfully imported {} stores.", repository.count()); log.info("Successfully imported {} stores.", repository.count());
} }

View File

@@ -21,7 +21,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.geo.Distance; import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point; import org.springframework.data.geo.Point;
import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.querydsl.binding.QuerydslBindings; import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.data.rest.core.annotation.RestResource;
@@ -34,7 +34,7 @@ import com.querydsl.core.types.dsl.StringPath;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public interface StoreRepository extends PagingAndSortingRepository<Store, UUID>, QueryDslPredicateExecutor<Store> { public interface StoreRepository extends PagingAndSortingRepository<Store, UUID>, QuerydslPredicateExecutor<Store> {
@RestResource(rel = "by-location") @RestResource(rel = "by-location")
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable); Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);

View File

@@ -28,9 +28,9 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links; import org.springframework.hateoas.Links;

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId> <artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -18,9 +18,8 @@ package example.springdata.rest.uris;
import lombok.NonNull; import lombok.NonNull;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.io.Serializable; import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.core.support.EntityLookup; import org.springframework.data.rest.core.support.EntityLookup;
import org.springframework.data.rest.core.support.EntityLookupSupport; import org.springframework.data.rest.core.support.EntityLookupSupport;
@@ -33,7 +32,7 @@ import org.springframework.data.rest.core.support.EntityLookupSupport;
* @author Oliver Gierke * @author Oliver Gierke
* @see SpringDataRestCustomization#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration) * @see SpringDataRestCustomization#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration)
*/ */
@RequiredArgsConstructor(onConstructor = @__(@Autowired) ) @RequiredArgsConstructor
public class UserEntityLookup extends EntityLookupSupport<User> { public class UserEntityLookup extends EntityLookupSupport<User> {
private final @NonNull UserRepository repository; private final @NonNull UserRepository repository;
@@ -43,16 +42,16 @@ public class UserEntityLookup extends EntityLookupSupport<User> {
* @see org.springframework.data.rest.core.support.EntityLookup#getId(java.lang.Object) * @see org.springframework.data.rest.core.support.EntityLookup#getId(java.lang.Object)
*/ */
@Override @Override
public Serializable getResourceIdentifier(User entity) { public Object getResourceIdentifier(User entity) {
return entity.getUsername(); return entity.getUsername();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.rest.core.support.EntityLookup#lookupEntity(java.io.Serializable) * @see org.springframework.data.rest.core.support.EntityLookup#lookupEntity(java.lang.Object)
*/ */
@Override @Override
public Object lookupEntity(Serializable id) { public Optional<User> lookupEntity(Object id) {
return repository.findByUsername(id.toString()); return repository.findByUsername(id.toString());
} }
} }

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-solr-examples</artifactId> <artifactId>spring-data-solr-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-solr-example</artifactId> <artifactId>spring-data-solr-example</artifactId>

View File

@@ -65,7 +65,7 @@ public class AdvancedSolrRepositoryTests {
Product superNES = Product.builder().id("id-3").name("Super Nintendo").popularity(3).build(); Product superNES = Product.builder().id("id-3").name("Super Nintendo").popularity(3).build();
Product nintendo64 = Product.builder().id("id-4").name("N64").description("Nintendo 64").popularity(2).build(); Product nintendo64 = Product.builder().id("id-4").name("N64").description("Nintendo 64").popularity(2).build();
repository.save(Arrays.asList(playstation, playstation2, superNES, nintendo64)); repository.saveAll(Arrays.asList(playstation, playstation2, superNES, nintendo64));
} }
} }

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-solr-examples</artifactId> <artifactId>spring-data-solr-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-solr-managed-schema-example</artifactId> <artifactId>spring-data-solr-managed-schema-example</artifactId>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<name>Spring Data Solr - Examples</name> <name>Spring Data Solr - Examples</name>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-solr-examples</artifactId> <artifactId>spring-data-solr-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<artifactId>spring-data-solr-example-utils</artifactId> <artifactId>spring-data-solr-example-utils</artifactId>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-web-examples</artifactId> <artifactId>spring-data-web-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId> <artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<name>Spring Data - Web examples</name> <name>Spring Data - Web examples</name>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-web-examples</artifactId> <artifactId>spring-data-web-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.data.examples</groupId> <groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-web-examples</artifactId> <artifactId>spring-data-web-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version> <version>2.0.0.BUILD-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>
@@ -27,7 +27,6 @@
<dependency> <dependency>
<groupId>com.querydsl</groupId> <groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId> <artifactId>querydsl-mongodb</artifactId>
<version>${querydsl.version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.mongodb</groupId> <groupId>org.mongodb</groupId>
@@ -116,7 +115,7 @@
<goal>process</goal> <goal>process</goal>
</goals> </goals>
<configuration> <configuration>
<outputDirectory>target/generated-sources/annotations</outputDirectory> <outputDirectory>target/generated-sources/queries</outputDirectory>
<processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor> <processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
<logOnlyOnError>true</logOnlyOnError> <logOnlyOnError>true</logOnlyOnError>
</configuration> </configuration>

View File

@@ -52,7 +52,7 @@ public class UserInitializer {
List<User> users = readUsers(new ClassPathResource("randomuser.me.csv")); List<User> users = readUsers(new ClassPathResource("randomuser.me.csv"));
repository.deleteAll(); repository.deleteAll();
repository.save(users); repository.saveAll(users);
} }
private static List<User> readUsers(Resource resource) throws Exception { private static List<User> readUsers(Resource resource) throws Exception {

View File

@@ -15,7 +15,7 @@
*/ */
package example.users; package example.users;
import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
import org.springframework.data.querydsl.binding.QuerydslBindings; import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
@@ -31,7 +31,7 @@ import com.querydsl.core.types.dsl.StringPath;
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public interface UserRepository public interface UserRepository
extends CrudRepository<User, String>, QueryDslPredicateExecutor<User>, QuerydslBinderCustomizer<QUser> { extends CrudRepository<User, String>, QuerydslPredicateExecutor<User>, QuerydslBinderCustomizer<QUser> {
/* /*
* (non-Javadoc) * (non-Javadoc)