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

Add support for limiting the query result in the query derivation mechanism.

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.9 M1 (Evans)
    • Component/s: Repositories
    • Labels:

      Description

      In order to make common use cases like finding the record with the biggest or smallest property value and finding the top K customers based on customer value
      we should provide a way to express those queries via the query derivation mechanism.

      This could look like the following:

      General form:

      (Entity, Optional<Entity>, Iterable<Entity>, Collection+<Entity>) findFirstNByAAA...

      For N = 1: we allow the following return types:
      (Note that findFirstBy will be handled as findFirst1By)

      (Entity, Optional<Entity>, Iterable<Entity>, Collection+<Entity>) findFirstNByAAA...
      

      and for N > 1:

      (Iterable<Entity>, Collection+<Entity>) findFirstNByAAA...
      

      Note that instead of the First keyword one could also use the Top keyword.

      This would enable us to do the following:

       findFirstByXXXOrderByYYYYAsc (=smallest)
       findFirstByXXXOrderByYYYYDesc (=greatest)
       findTopByXXXOrderByYYYYDesc (=greatest)
       findFirstByXXX(Sort sort) (general purpose)
       findTopByXXX(Sort sort) (general purpose)
       findFirstKByXXXOrderByYYYYAsc (=smallest K)
       findFirstKByXXXOrderByYYYYDesc (=biggest K)
       findFirstKByXXX(Sort sort) (general purpose TOP K)
       findTopKByXXX(Sort sort) (general purpose TOP K)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              thomasd Thomas Darimont
              Reporter:
              thomasd Thomas Darimont
              Last updater:
              Oliver Drotbohm
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: