Skip to content

DATACMNS-1058 - Alter QueryByExampleExecutor.findOne to return Optional. #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.DATACMNS-1058-SNAPSHOT</version>

<name>Spring Data Core</name>

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -25,6 +27,7 @@
*
* @param <T>
* @author Mark Paluch
* @author Christoph Strobl
* @since 1.12
*/
public interface QueryByExampleExecutor<T> {
Expand All @@ -33,10 +36,10 @@ public interface QueryByExampleExecutor<T> {
* 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 extends T> S findOne(Example<S> example);
<S extends T> Optional<S> findOne(Example<S> example);

/**
* Returns all entities matching the given {@link Example}. In case no match could be found an empty {@link Iterable}
Expand Down