From 7c856c80c256ce995705bea06557bdc1e5a3f417 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Fri, 5 May 2017 14:18:46 +0200 Subject: [PATCH 1/2] DATACMNS-1058 - Prepare issue branch. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1db9b70ebb..6ecfed3780 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-commons - 2.0.0.BUILD-SNAPSHOT + 2.0.0.DATACMNS-1058-SNAPSHOT Spring Data Core From 22a23c057c0ec8113cd21f8b2256422ea134ed70 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Fri, 5 May 2017 14:28:56 +0200 Subject: [PATCH 2/2] DATACMNS-1058 - Alter QueryByExampleExecuter.findOne to return Optional. We now return Optional for findOne() just as we do in CrudRepository. --- .../data/repository/query/QueryByExampleExecutor.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/springframework/data/repository/query/QueryByExampleExecutor.java b/src/main/java/org/springframework/data/repository/query/QueryByExampleExecutor.java index a5421e27f2..2288e86d73 100644 --- a/src/main/java/org/springframework/data/repository/query/QueryByExampleExecutor.java +++ b/src/main/java/org/springframework/data/repository/query/QueryByExampleExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package org.springframework.data.repository.query; +import java.util.Optional; + import org.springframework.data.domain.Example; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -25,6 +27,7 @@ * * @param * @author Mark Paluch + * @author Christoph Strobl * @since 1.12 */ public interface QueryByExampleExecutor { @@ -33,10 +36,10 @@ public interface QueryByExampleExecutor { * Returns a single entity matching the given {@link Example} or {@literal null} if none was found. * * @param example can be {@literal null}. - * @return a single entity matching the given {@link Example} or {@literal null} if none was found. + * @return a single entity matching the given {@link Example} or {@link Optional#empty()} if none was found. * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if the Example yields more than one result. */ - S findOne(Example example); + Optional findOne(Example example); /** * Returns all entities matching the given {@link Example}. In case no match could be found an empty {@link Iterable}