OpenJPA
  1. OpenJPA
  2. OPENJPA-2228

QuerySQLCache broken for Entities with @EmbeddedId

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0, 2.3.0
    • Fix Version/s: 2.3.0
    • Component/s: query
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      Multiple calls of a query which has some Relationships with @EmbeddedId fields fails if QuerySQLCache is enabled.

      q = em.createQuery("select l from ListTest l where l.te=:test");
      does create:
      SELECT t0.id, t0.keyA, t0.keyB, t0.keyC, t1.keyA, t1.keyB, t1.keyC, t1.data1,
      t1.data2
      FROM ListTest t0 LEFT OUTER JOIN TestEntity t1 ON t0.keyA = t1.keyA AND t0.keyB
      = t1.keyB AND t0.keyC = t1.keyC
      WHERE (t0.keyA = ? AND t0.keyB = ? AND t0.keyC = ?)
      [params=(int) 1, (int) 2, (int) 3]

      however a second query will create:
      q = em.createQuery("select l from ListTest l where l.te=:test");
      SELECT t0.id, t0.keyA, t0.keyB, t0.keyC, t1.keyA, t1.keyB, t1.keyC, t1.data1,
      t1.data2
      FROM ListTest t0 LEFT OUTER JOIN TestEntity t1 ON t0.keyA = t1.keyA AND t0.keyB
      = t1.keyB AND t0.keyC = t1.keyC
      WHERE (t0.keyA = ? AND t0.keyB = ? AND t0.keyC = ?)
      [params=(int) 3, (int) 2, (int) 3]

      Note the wrong first param !
      (There is some Index filed calculated somewhere in the query and the index Array has [0,0,0] as values, so the 0th position does get updated three times .. the bug should be something with the index i think)

      See attached test-project

      1. openjpaBugreport.zip
        6 kB
        Michael Glauche
      2. OPENJPA-2228.patch
        15 kB
        Helen Xu

        Activity

        Hide
        Michael Glauche added a comment -

        Small demo for bug, see failing maven test, it works if QuerySqlCache is disabled

        Show
        Michael Glauche added a comment - Small demo for bug, see failing maven test, it works if QuerySqlCache is disabled
        Hide
        Helen Xu added a comment -

        I was able to reproduce the problem.

        user parameter index got messed up when there are duplicate param key.

        the fix and unit test attached.

        Show
        Helen Xu added a comment - I was able to reproduce the problem. user parameter index got messed up when there are duplicate param key. the fix and unit test attached.
        Hide
        Rick Curtis added a comment -

        Helen - It looks like you missed something when you created the patch.... it only has a testcase.

        Show
        Rick Curtis added a comment - Helen - It looks like you missed something when you created the patch.... it only has a testcase.
        Hide
        Helen Xu added a comment -

        Sorry, I didn't include the actual fix which is in openjpa-jdbc.

        new patch attached.

        Show
        Helen Xu added a comment - Sorry, I didn't include the actual fix which is in openjpa-jdbc. new patch attached.
        Hide
        Rick Curtis added a comment -

        Committed revision 1362679 to trunk. Thanks for the patch Helen!

        Show
        Rick Curtis added a comment - Committed revision 1362679 to trunk. Thanks for the patch Helen!

          People

          • Assignee:
            Helen Xu
            Reporter:
            Michael Glauche
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development