Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1511

Derived finder does not throw IncorrectResultSizeDataAccessException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.4 (Hopper SR4)
    • Fix Version/s: None
    • Component/s: Repository
    • Labels:

      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..

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mp911de Mark Paluch
                Reporter:
                frant.hartm FrantiĊĦek Hartman
                Last updater:
                Mark Paluch
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: