Cayenne
  1. Cayenne
  2. CAY-928

Ordering across relationship should use left join

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core Library
    • Labels:
      None

      Description

      When ordering across a relationship like this:

      SelectQuery qual = new SelectQuery(Painting.class);
      qual.addOrdering(new Ordering(Painting.ARTIST_PROPERTY+"."+Artist.NAME_PROPERTY, true, true));

      the SQL looks like this:

      SELECT t0.id FROM Painting t0, Artist t1 WHERE t0.artistId = t1.id ORDER BY t1.name

      but it should be like this:

      SELECT t0.id FROM Painting t0 LEFT JOIN Artist t1 ON t0.artistId = t1.id ORDER BY t1.name

      What this means is that at the moment Cayenne will exclude from this query all paintings with no related artist.

      Regardless of how one thinks NULLs should be sorted in this relationship, the addition of a new Ordering in Cayenne shouldn't change the number of records returned from the SelectQuery.

        Issue Links

          Activity

          Ari Maniatis made changes -
          Workflow jira [ 12456743 ] Cayenne workflow [ 12487236 ]
          Henri Yandell made changes -
          Project Import Sat Mar 21 00:51:04 PDT 2009 [ 1237621864637 ]
          Andrus Adamchik made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Ari Maniatis made changes -
          Link This issue references CAY-929 [ CAY-929 ]
          Ari Maniatis made changes -
          Field Original Value New Value
          Summary Ordering across relationship should use inner join Ordering across relationship should use left join
          Ari Maniatis created issue -

            People

            • Assignee:
              Andrus Adamchik
              Reporter:
              Ari Maniatis
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development