OpenJPA
  1. OpenJPA
  2. OPENJPA-2147

Inability to use Prepared SQL Query Cache and 'Identity Class' @IdClass

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.2.0
    • Fix Version/s: None
    • Component/s: jdbc
    • Labels:
      None

      Description

      There is an entity Node2 which is using an identity class.
      It is introduced in an unit test attached to related issue OPENJPA-2144.

      I have made two sequential queries to Node2 at the same transaction, but different query objects in order to use prepared SQL query Cache.

      JPQL: SELECT p FROM Node2 p WHERE p.parent = :parent

      Not cached query works fine and returns not empty list:

      302884 test TRACE [main] openjpa.Runtime - Query "SELECT p FROM Node2 p WHERE p.parent = :parent" is cached."
      302884 test TRACE [main] openjpa.Query - Executing query: [SELECT p FROM Node2 p WHERE p.parent = :parent] with parameters:

      {parent=1351::1::2}

      302962 test TRACE [main] openjpa.jdbc.SQL - <t 5142872, conn 30621423> executing prepstmnt 21961831 SELECT t0.district, t0.id, t0.region, t0.version, t0.data, t0.PARENT_ID FROM NODE2 t0 WHERE (t0.PARENT_ID = ? AND t0.region = ? AND t0.district = ?) [params=(long) 1351, (int) 1, (int) 2]

      Sequential cached query returns empty list:

      346242 test TRACE [main] openjpa.Query - Executing query: [SELECT p FROM Node2 p WHERE p.parent = :parent] with parameters:

      {0=1, 1=1, 2=2}

      346242 test TRACE [main] openjpa.jdbc.SQL - <t 5142872, conn 30621423> executing prepstmnt 13122813 SELECT t0.district, t0.id, t0.region, t0.version, t0.data, t0.PARENT_ID FROM NODE2 t0 WHERE (t0.PARENT_ID = ? AND t0.region = ? AND t0.district = ?) [params=(int) 1, (int) 1, (int) 2]

      You can see that wrong paraments were passed into the cached generated raw SQL in the second query!

      That is the problem, we have wrong query result.

        Issue Links

          Activity

          Dmitry Pavlov created issue -
          Dmitry Pavlov made changes -
          Field Original Value New Value
          Description There is an entity Node2 which is using an identity class.
          It is introduced in an unit test attached to related issue OPENJPA-2144.

          I have made to sequential queries to Node2 at the same transaction, but different query objects in order to use prepared SQL query Cache.

          JPQL: SELECT p FROM Node2 p WHERE p.parent = :parent

          Not cached query works fine and returns not empty list:

          302884 test TRACE [main] openjpa.Runtime - Query "SELECT p FROM Node2 p WHERE p.parent = :parent" is cached."
          302884 test TRACE [main] openjpa.Query - Executing query: [SELECT p FROM Node2 p WHERE p.parent = :parent] with parameters: {parent=1351::1::2}
          302962 test TRACE [main] openjpa.jdbc.SQL - <t 5142872, conn 30621423> executing prepstmnt 21961831 SELECT t0.district, t0.id, t0.region, t0.version, t0.data, t0.PARENT_ID FROM NODE2 t0 WHERE (t0.PARENT_ID = ? AND t0.region = ? AND t0.district = ?) [params=(long) 1351, (int) 1, (int) 2]

          Sequential cached query returns empty list:

          346242 test TRACE [main] openjpa.Query - Executing query: [SELECT p FROM Node2 p WHERE p.parent = :parent] with parameters: {0=1, 1=1, 2=2}
          346242 test TRACE [main] openjpa.jdbc.SQL - <t 5142872, conn 30621423> executing prepstmnt 13122813 SELECT t0.district, t0.id, t0.region, t0.version, t0.data, t0.PARENT_ID FROM NODE2 t0 WHERE (t0.PARENT_ID = ? AND t0.region = ? AND t0.district = ?) [params=(int) 1, (int) 1, (int) 2]

          You can see that wrong paraments were passed into cached generated raw SQL in the second query!

          That is the problem, we have wrong query result.
          There is an entity Node2 which is using an identity class.
          It is introduced in an unit test attached to related issue OPENJPA-2144.

          I have made two sequential queries to Node2 at the same transaction, but different query objects in order to use prepared SQL query Cache.

          JPQL: SELECT p FROM Node2 p WHERE p.parent = :parent

          Not cached query works fine and returns not empty list:

          302884 test TRACE [main] openjpa.Runtime - Query "SELECT p FROM Node2 p WHERE p.parent = :parent" is cached."
          302884 test TRACE [main] openjpa.Query - Executing query: [SELECT p FROM Node2 p WHERE p.parent = :parent] with parameters: {parent=1351::1::2}
          302962 test TRACE [main] openjpa.jdbc.SQL - <t 5142872, conn 30621423> executing prepstmnt 21961831 SELECT t0.district, t0.id, t0.region, t0.version, t0.data, t0.PARENT_ID FROM NODE2 t0 WHERE (t0.PARENT_ID = ? AND t0.region = ? AND t0.district = ?) [params=(long) 1351, (int) 1, (int) 2]

          Sequential cached query returns empty list:

          346242 test TRACE [main] openjpa.Query - Executing query: [SELECT p FROM Node2 p WHERE p.parent = :parent] with parameters: {0=1, 1=1, 2=2}
          346242 test TRACE [main] openjpa.jdbc.SQL - <t 5142872, conn 30621423> executing prepstmnt 13122813 SELECT t0.district, t0.id, t0.region, t0.version, t0.data, t0.PARENT_ID FROM NODE2 t0 WHERE (t0.PARENT_ID = ? AND t0.region = ? AND t0.district = ?) [params=(int) 1, (int) 1, (int) 2]

          You can see that wrong paraments were passed into the cached generated raw SQL in the second query!

          That is the problem, we have wrong query result.
          Dmitry Pavlov made changes -
          Link This issue relates to OPENJPA-2144 [ OPENJPA-2144 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Dmitry Pavlov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Development