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

Property API: unable to use eq() and in() methods for toMany relationships

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.2.M1
    • Component/s: None
    • Labels:
      None

      Description

      Following code won't compile as eq() (as well as in()) method require List<Paintings> or other Property<> in this case, but everything else down the stack will correctly translate and execute this query and return correct result (I've checked this by simply allowing Object as argument in eq())

                      
          Painting painting = ObjectSelect.query(Painting.class).selectFirst(context);
          Artist artist = ObjectSelect.query(Artist.class)
                  .where(Artist.PAINTING_ARRAY.eq(painting))
                  .selectFirst(context);
      

      Generated SQL:

      SELECT DISTINCT t0.ARTIST_NAME, t0.DATE_OF_BIRTH, t0.ARTIST_ID 
      FROM ARTIST t0 
      JOIN PAINTING t1 ON (t0.ARTIST_ID = t1.ARTIST_ID) 
      WHERE t1.PAINTING_ID = ? 
      LIMIT 1 OFFSET 0 
      [bind: 1->PAINTING_ID:1]
      

      Workaround can be parsing expression from string:
      .where(ExpressionFactory.exp("paintingArray = $p", painting))

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ntimofeev Nikita Timofeev
                Reporter:
                ntimofeev Nikita Timofeev
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: