You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Dmitry Pavlov (Updated) (JIRA)" <ji...@apache.org> on 2012/02/28 05:37:48 UTC

[jira] [Updated] (OPENJPA-2147) Inability to use Prepared SQL Query Cache and 'Identity Class' @IdClass

     [ https://issues.apache.org/jira/browse/OPENJPA-2147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitry Pavlov updated OPENJPA-2147:
-----------------------------------

    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.


  was:
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.


    
> Inability to use Prepared SQL Query Cache and 'Identity Class' @IdClass
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2147
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2147
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.2.0
>            Reporter: Dmitry Pavlov
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira