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 d1d0c491..f924e9db 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 @@ -35,11 +35,29 @@ public interface CustomerRepository extends Repository { */ Optional findOne(Long id); + /** + * Saves the given {@link Customer}. + * + * @param customer + * @return + */ S save(S customer); + /** + * Sample method to derive a query from using JDK 8's {@link Optional} as return type. + * + * @param lastname + * @return + */ Optional findByLastname(String lastname); + /** + * Sample default method to show JDK 8 feature support. + * + * @param customer + * @return + */ default Optional findByLastname(Customer customer) { - return findByLastname(customer.lastname); + return findByLastname(customer == null ? null : customer.lastname); } }