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

Allow projections in derived finder methods

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Sprint:
      57 - Fowler Aftermath, 58 - Gosling M1, 59 - Evans / Fowler SR, Gosling RC1

      Description

      The findBy clause of the derived queries currently allows setting a distinct flag already. We could add property projections as well:

      interface PersonRepository extends Repository<Person, Long> {
       
        List<Map<String, String>> findNameAndAgeByGroupTitle(String title);
      }

      The return types should act as follows:

      • Map<String, ${type or Object}> expecting a single returned result consisting of multiple key-value pairs.
      • ${type} - expecting a single result. We'll trigger a DTO projection, e.g. select new ${type}(name, age) ...
      • Iterable of both possibilities triggering the very same expecting multiple results
      • Page of both triggering pagination.

        Issue Links

          Activity

          Hide
          stanaccy Nick Pratt added a comment -

          We find a common operation is to load all values of a specific type without wanting to trigger a full object load. Something like List<String> findAllNames(); where 'name' is a property of the class. Supporting Set<String> findAllNames() to automatically provide a unique selection would be helpful.

          Show
          stanaccy Nick Pratt added a comment - We find a common operation is to load all values of a specific type without wanting to trigger a full object load. Something like List<String> findAllNames(); where 'name' is a property of the class. Supporting Set<String> findAllNames() to automatically provide a unique selection would be helpful.
          Hide
          alan-czajkowski Alan Czajkowski added a comment - - edited

          agreed, i would really like to load a list of one (or more attributes), examples:

          List<Long> findId()

          List<Map<String, Object>> findIdAndName()

          Show
          alan-czajkowski Alan Czajkowski added a comment - - edited agreed, i would really like to load a list of one (or more attributes), examples: List<Long> findId() List<Map<String, Object>> findIdAndName()

            People

            • Assignee:
              olivergierke Oliver Gierke
              Reporter:
              mhunger Michael Hunger
              Last updater:
              Oliver Gierke
            • Votes:
              14 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 0.5d
                0.5d
                Remaining:
                Remaining Estimate - 0.5d
                0.5d
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Agile