Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-574

Change CrudRepository to return Optional<T> as return values instead of null reference or provide alternative base interface

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      As described in the StackOverflow question, I think it would be a big improvement if the repositories returned an Optional<T> instead of possible null references when querying single objects.

      Maybe you can consider this when you drop the support for JDK 6 and 7, and plan your next major release. Or you could introduce your own implementation for the Optional<T>, like the guava team did, when not dropping the JDK support for 6 and 7.

      This change would only effect some of the CrudRepository interface methods. And the implementation is almost trivial.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              marcelhaerle Marcel Härle
              Last updater:
              Spring Issues Spring Issues
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: