Spring Data Commons
  1. Spring Data Commons
  2. DATACMNS-89

Allow projections in derived finder methods

    Details

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

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

            People

            • Assignee:
              Oliver Gierke
              Reporter:
              Michael Hunger
            • Votes:
              7 Vote for this issue
              Watchers:
              5 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