Skip to content
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

T result from repository finder should throw exception when there is not a single unique result [DATAGRAPH-948] #1509

Closed
spring-projects-issues opened this issue Jan 12, 2017 · 1 comment
Assignees
Labels
in: core
Milestone

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Jan 12, 2017

Mark Angrish opened DATAGRAPH-948 and commented

SDN should follow Spring Data conventions where it can.

??"T | An unique entity. Expects the query method to return one result at most. In case no result is found null is returned. More than one result will trigger an IncorrectResultSizeDataAccessException."??

From: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repository-query-return-types

Test case:

    @Test(expected = IncorrectResultSizeDataAccessException.class)
    public void findByNameSingleResult() throws Exception {
        World world1 = new World("world 1", 1);
        worldRepository.save(world1, 0);

        World world2 = new World("world 1", 2);
        worldRepository.save(world2, 0);

        World world = worldRepository.findByName("world 1"); // there are 2 results, 1 is returned instead of IncorrectResultSizeDataAccessException thrown
    }

Affects: 4.2 RC1 (Ingalls), 5.0 M1 (Kay)

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 4, 2017

Gerrit Meier commented

Due to refactoring driven by DATAGRAPH-975 this was already resolved.
Added regression test for completeness

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core
Projects
None yet
Development

No branches or pull requests

2 participants