From 0ff53bd5dbe466cb613b199c256d006c3b30d710 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Fri, 5 May 2017 14:28:56 +0200 Subject: [PATCH] DATACMNS-1058 - Alter QueryByExampleExecutor.findOne to return Optional. We now return Optional for findOne() just as we do in CrudRepository. Original pull request: #214. --- .../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 a5421e27f..2288e86d7 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 @@ import org.springframework.data.domain.Sort; * * @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}