Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2032

SelectAction: DistinctResultIterator ignores flattened relationships

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.M3
    • 4.0.M5
    • Core Library
    • None
    • MySQL database
      Cayenne 4.0.M3.debfa94

    Description

      Let's take a look at the example:
      Cayenne model: Team and User entities, many-to-many relationship between them.
      Data: There are 3 teams and a user, who is linked to all these teams.

      We're trying to fetch Teams and their related Users (via the prefetching) by using any of disjoint semantics (perhaps it doesn't matter what semantic is being used in this case).
      Thus Cayenne engine performs 2 queries:
      1. To fetch Team records;
      2. To fetch User records:
      SELECT t0.*, t2.id FROM user t0
      JOIN user_has_team t1 ON (t0.id = t1.user_id)
      JOIN team t2 ON (t1.team_id = t2.id);
      3 records are resulted from the 2nd query execution. The records are differs by "t2.id" column (it's a Team id), so they are not distinct.
      And as a result DistinctResultIterator should take this fact into account during processing the results.

      Attachments

        Activity

          People

            ntimofeev Nikita Timofeev
            dkoyro Denis Koyro
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: