[DATAMONGO-1511] Derived finder does not throw IncorrectResultSizeDataAccessException Created: 14/Oct/16  Updated: 12/Nov/19  Resolved: 12/Nov/19

Status: Closed
Project: Spring Data MongoDB
Component/s: Repository
Affects Version/s: 1.9.4 (Hopper SR4)
Fix Version/s: None

Type: Bug Priority: Major
Reporter: FrantiĊĦek Hartman Assignee: Mark Paluch
Resolution: Fixed Votes: 0
Labels: lovelace
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relate
is related to DATAMONGO-1865 findFirst query method throws Incorre... Closed
is related to DATAMONGO-1738 Move to fluent API for repository que... Closed
Last updater: Mark Paluch

 Description   

I have a simple derived finder:

MyType findByProperty(String property);

I have multiple records in the collection, whey I call the finder I expect an exception as described in the documentation

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

http://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#repository-query-return-types

Right now (with 1.9.4) it returns one of the results.

I can see following in my log
17:21:31.458 [main] DEBUG org.springframework.data.mongodb.core.MongoTemplate - findOne using query:

{ "property" : "value"}

in db.collection: my-test.myType

If I pass the query to mongo manually it returns multiple results, if I change the return type to a collection then all results are returned, but I need single entity with exception..



 Comments   
Comment by Mark Paluch [ 12/Nov/19 ]

That issue was fixed with DATAMONGO-1738 and DATAMONGO-1865.

Generated at Sat Nov 23 01:08:05 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.