diff --git a/jpa/java8/pom.xml b/jpa/java8/pom.xml
index 1e6a5eb7..653c7884 100644
--- a/jpa/java8/pom.xml
+++ b/jpa/java8/pom.xml
@@ -10,6 +10,10 @@
spring-data-jpa-java8
Spring Data JPA - Java 8 specific features
+
+
+ Evans-BUILD-SNAPSHOT
+
diff --git a/jpa/java8/src/main/java/example/springdata/jpa/java8/CustomerRepository.java b/jpa/java8/src/main/java/example/springdata/jpa/java8/CustomerRepository.java
index d4113f42..d1d0c491 100644
--- a/jpa/java8/src/main/java/example/springdata/jpa/java8/CustomerRepository.java
+++ b/jpa/java8/src/main/java/example/springdata/jpa/java8/CustomerRepository.java
@@ -36,4 +36,10 @@ public interface CustomerRepository extends Repository {
Optional findOne(Long id);
S save(S customer);
+
+ Optional findByLastname(String lastname);
+
+ default Optional findByLastname(Customer customer) {
+ return findByLastname(customer.lastname);
+ }
}
diff --git a/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java b/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java
index 7a8d8f76..4275ab9e 100644
--- a/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java
+++ b/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java
@@ -56,4 +56,14 @@ public class Java8IntegrationTests {
assertThat(customer.createdDate, is(notNullValue()));
assertThat(customer.modifiedDate, is(notNullValue()));
}
+
+ @Test
+ public void invokesDefaultMethod() {
+
+ Customer customer = repository.save(new Customer("Dave", "Matthews"));
+ Optional result = repository.findByLastname(customer);
+
+ assertThat(result.isPresent(), is(true));
+ assertThat(result.get(), is(customer));
+ }
}