You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Mark Struberg <st...@yahoo.de> on 2010/10/19 18:35:59 UTC

QueryCacheImpl question

Hi!

I have a problem with upgrading from OpenJPA-2.0.0 to 2.0.1.

One of my services executes the following query (this is the 'id' I get in PreparedQueryCacheImpl#get(String id) ):

SELECT distinct e FROM Employment em, Person e WHERE em.employeeId = e.employeeId and em.orgUnitCode = :orgUnitCode AND em.employmentPosition in (:employmentPositions) AND em.start <= :startBefore AND em.end >= :endAfter ORDER BY e.familyName ASC

Somehow when I execute my service a few times with different employmentPositions params (ArrayList<String>) I still get the 'old' cached param values! 

I tried to disable this behaviour in my persistence.xml with

  <property name="openjpa.QueryCache" value="false"/>

but this didn't work.

Maybe this was a side effect of the ORDER BY which made this query work in 2.0.0 (caching of queries with ORDER BY got only fixed after 2.0.0), so I'd like to write a unit test for it.
Imo it's not that easy to cache queries with a select IN, wdyt?


keep u updated, but feel free to ping me if this is a known issue ...

txs and LieGrue,
strub


      

Re: QueryCacheImpl question

Posted by Mark Struberg <st...@yahoo.de>.
Hi Jeremy!

I've now created a JIRAffe [1] to track this issue and currently compiling the latest 2.0.1-SNAPSHOT from SVN.
To me it's not yet clear if the caching strategy used in the source can work out for queries with variable '?' in the prepared statement anyway. 

It is absolutely not clear to me why the 'params' are retrieved from a previously stored query. Any explanation? 

LieGrue,
strub

[1] https://issues.apache.org/jira/browse/OPENJPA-1845

--- On Tue, 10/19/10, Jeremy Bauer <te...@gmail.com> wrote:

> From: Jeremy Bauer <te...@gmail.com>
> Subject: Re: QueryCacheImpl question
> To: dev@openjpa.apache.org
> Date: Tuesday, October 19, 2010, 5:55 PM
> Hi Mark,
> 
> Very glad to hear that worked for you.  That property
> is actually documented
> in a different section of the manual[1].
> 
> Any chance you could try running with the latest 2.0.x or
> 2.1.x level code
> from the nightly build?  At least one fix has gone in
> for a
> QuerySQLCache/PreparedSQLCache related bug recently. 
> There's a slim chance,
> but it or another JIRA may have corrected the
> problem.   If you still hit
> the problem, please file a JIRA, and if you can, attach a
> simple testcase.
> That'll help speed up resolution.
> 
> Thanks,
> -Jeremy
> 
> [1]
> http://openjpa.apache.org/builds/2.0.0-M3/apache-openjpa-2.0.0-M3/docs/manual/ref_guide_conf_jdbc.html#openjpa.jdbc.QuerySQLCache
> 
> On Tue, Oct 19, 2010 at 12:20 PM, Mark Struberg <st...@yahoo.de>
> wrote:
> 
> > Hi Jeremy!
> >
> > Big thanks for the hint to the 'hidden' config param.
> My regression tests
> > are now working again.
> >
> > Should I create a JIRAffe or will you create one?
> >
> > It would maybe also be a good idea to document it in
> the OpenJPA Properties
> > documentation section [1]?
> >
> >
> > txs and LieGrue,
> > strub
> >
> >
> > http://openjpa.apache.org/builds/2.0.0-M3/apache-openjpa-2.0.0-M3/docs/manual/ref_guide_conf_openjpa.html
> >
> >
> > --- On Tue, 10/19/10, Jeremy Bauer <te...@gmail.com>
> wrote:
> >
> > > From: Jeremy Bauer <te...@gmail.com>
> > > Subject: Re: QueryCacheImpl question
> > > To: dev@openjpa.apache.org
> > > Date: Tuesday, October 19, 2010, 4:47 PM
> > > Hi Mark,
> > >
> > > OpenJPA has a query result cache (QueryCache) for
> caching
> > > full query results
> > > and a SQL query cache (QuerySQLCache) for caching
> SQL
> > > queries. You've
> > > disabled the QueryCache (which is actually
> disabled by
> > > default).  I believe
> > > the bug you've hit is in the query SQL
> cache.  Try
> > > disabling the query SQL
> > > cache via:
> > >
> > > <property name="openjpa.jdbc.QuerySQLCache"
> > > value="false"/>
> > >
> > > hth,
> > > -Jeremy
> > >
> > > On Tue, Oct 19, 2010 at 11:35 AM, Mark Struberg
> <st...@yahoo.de>
> > > wrote:
> > >
> > > > Hi!
> > > >
> > > > I have a problem with upgrading from
> OpenJPA-2.0.0 to
> > > 2.0.1.
> > > >
> > > > One of my services executes the following
> query (this
> > > is the 'id' I get in
> > > > PreparedQueryCacheImpl#get(String id) ):
> > > >
> > > > SELECT distinct e FROM Employment em, Person
> e WHERE
> > > em.employeeId =
> > > > e.employeeId and em.orgUnitCode =
> :orgUnitCode AND
> > > em.employmentPosition in
> > > > (:employmentPositions) AND em.start <=
> :startBefore
> > > AND em.end >= :endAfter
> > > > ORDER BY e.familyName ASC
> > > >
> > > > Somehow when I execute my service a few
> times with
> > > different
> > > > employmentPositions params
> (ArrayList<String>) I
> > > still get the 'old' cached
> > > > param values!
> > > >
> > > > I tried to disable this behaviour in my
> > > persistence.xml with
> > > >
> > > >  <property
> name="openjpa.QueryCache"
> > > value="false"/>
> > > >
> > > > but this didn't work.
> > > >
> > > > Maybe this was a side effect of the ORDER BY
> which
> > > made this query work in
> > > > 2.0.0 (caching of queries with ORDER BY got
> only fixed
> > > after 2.0.0), so I'd
> > > > like to write a unit test for it.
> > > > Imo it's not that easy to cache queries with
> a select
> > > IN, wdyt?
> > > >
> > > >
> > > > keep u updated, but feel free to ping me if
> this is a
> > > known issue ...
> > > >
> > > > txs and LieGrue,
> > > > strub
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
> 


      

Re: QueryCacheImpl question

Posted by Jeremy Bauer <te...@gmail.com>.
Hi Mark,

Very glad to hear that worked for you.  That property is actually documented
in a different section of the manual[1].

Any chance you could try running with the latest 2.0.x or 2.1.x level code
from the nightly build?  At least one fix has gone in for a
QuerySQLCache/PreparedSQLCache related bug recently.  There's a slim chance,
but it or another JIRA may have corrected the problem.   If you still hit
the problem, please file a JIRA, and if you can, attach a simple testcase.
That'll help speed up resolution.

Thanks,
-Jeremy

[1]
http://openjpa.apache.org/builds/2.0.0-M3/apache-openjpa-2.0.0-M3/docs/manual/ref_guide_conf_jdbc.html#openjpa.jdbc.QuerySQLCache

On Tue, Oct 19, 2010 at 12:20 PM, Mark Struberg <st...@yahoo.de> wrote:

> Hi Jeremy!
>
> Big thanks for the hint to the 'hidden' config param. My regression tests
> are now working again.
>
> Should I create a JIRAffe or will you create one?
>
> It would maybe also be a good idea to document it in the OpenJPA Properties
> documentation section [1]?
>
>
> txs and LieGrue,
> strub
>
>
> http://openjpa.apache.org/builds/2.0.0-M3/apache-openjpa-2.0.0-M3/docs/manual/ref_guide_conf_openjpa.html
>
>
> --- On Tue, 10/19/10, Jeremy Bauer <te...@gmail.com> wrote:
>
> > From: Jeremy Bauer <te...@gmail.com>
> > Subject: Re: QueryCacheImpl question
> > To: dev@openjpa.apache.org
> > Date: Tuesday, October 19, 2010, 4:47 PM
> > Hi Mark,
> >
> > OpenJPA has a query result cache (QueryCache) for caching
> > full query results
> > and a SQL query cache (QuerySQLCache) for caching SQL
> > queries. You've
> > disabled the QueryCache (which is actually disabled by
> > default).  I believe
> > the bug you've hit is in the query SQL cache.  Try
> > disabling the query SQL
> > cache via:
> >
> > <property name="openjpa.jdbc.QuerySQLCache"
> > value="false"/>
> >
> > hth,
> > -Jeremy
> >
> > On Tue, Oct 19, 2010 at 11:35 AM, Mark Struberg <st...@yahoo.de>
> > wrote:
> >
> > > Hi!
> > >
> > > I have a problem with upgrading from OpenJPA-2.0.0 to
> > 2.0.1.
> > >
> > > One of my services executes the following query (this
> > is the 'id' I get in
> > > PreparedQueryCacheImpl#get(String id) ):
> > >
> > > SELECT distinct e FROM Employment em, Person e WHERE
> > em.employeeId =
> > > e.employeeId and em.orgUnitCode = :orgUnitCode AND
> > em.employmentPosition in
> > > (:employmentPositions) AND em.start <= :startBefore
> > AND em.end >= :endAfter
> > > ORDER BY e.familyName ASC
> > >
> > > Somehow when I execute my service a few times with
> > different
> > > employmentPositions params (ArrayList<String>) I
> > still get the 'old' cached
> > > param values!
> > >
> > > I tried to disable this behaviour in my
> > persistence.xml with
> > >
> > >  <property name="openjpa.QueryCache"
> > value="false"/>
> > >
> > > but this didn't work.
> > >
> > > Maybe this was a side effect of the ORDER BY which
> > made this query work in
> > > 2.0.0 (caching of queries with ORDER BY got only fixed
> > after 2.0.0), so I'd
> > > like to write a unit test for it.
> > > Imo it's not that easy to cache queries with a select
> > IN, wdyt?
> > >
> > >
> > > keep u updated, but feel free to ping me if this is a
> > known issue ...
> > >
> > > txs and LieGrue,
> > > strub
> > >
> > >
> > >
> > >
> >
>
>
>
>

Re: QueryCacheImpl question

Posted by Mark Struberg <st...@yahoo.de>.
Hi Jeremy!

Big thanks for the hint to the 'hidden' config param. My regression tests are now working again. 

Should I create a JIRAffe or will you create one?

It would maybe also be a good idea to document it in the OpenJPA Properties documentation section [1]?


txs and LieGrue,
strub

http://openjpa.apache.org/builds/2.0.0-M3/apache-openjpa-2.0.0-M3/docs/manual/ref_guide_conf_openjpa.html


--- On Tue, 10/19/10, Jeremy Bauer <te...@gmail.com> wrote:

> From: Jeremy Bauer <te...@gmail.com>
> Subject: Re: QueryCacheImpl question
> To: dev@openjpa.apache.org
> Date: Tuesday, October 19, 2010, 4:47 PM
> Hi Mark,
> 
> OpenJPA has a query result cache (QueryCache) for caching
> full query results
> and a SQL query cache (QuerySQLCache) for caching SQL
> queries. You've
> disabled the QueryCache (which is actually disabled by
> default).  I believe
> the bug you've hit is in the query SQL cache.  Try
> disabling the query SQL
> cache via:
> 
> <property name="openjpa.jdbc.QuerySQLCache"
> value="false"/>
> 
> hth,
> -Jeremy
> 
> On Tue, Oct 19, 2010 at 11:35 AM, Mark Struberg <st...@yahoo.de>
> wrote:
> 
> > Hi!
> >
> > I have a problem with upgrading from OpenJPA-2.0.0 to
> 2.0.1.
> >
> > One of my services executes the following query (this
> is the 'id' I get in
> > PreparedQueryCacheImpl#get(String id) ):
> >
> > SELECT distinct e FROM Employment em, Person e WHERE
> em.employeeId =
> > e.employeeId and em.orgUnitCode = :orgUnitCode AND
> em.employmentPosition in
> > (:employmentPositions) AND em.start <= :startBefore
> AND em.end >= :endAfter
> > ORDER BY e.familyName ASC
> >
> > Somehow when I execute my service a few times with
> different
> > employmentPositions params (ArrayList<String>) I
> still get the 'old' cached
> > param values!
> >
> > I tried to disable this behaviour in my
> persistence.xml with
> >
> >  <property name="openjpa.QueryCache"
> value="false"/>
> >
> > but this didn't work.
> >
> > Maybe this was a side effect of the ORDER BY which
> made this query work in
> > 2.0.0 (caching of queries with ORDER BY got only fixed
> after 2.0.0), so I'd
> > like to write a unit test for it.
> > Imo it's not that easy to cache queries with a select
> IN, wdyt?
> >
> >
> > keep u updated, but feel free to ping me if this is a
> known issue ...
> >
> > txs and LieGrue,
> > strub
> >
> >
> >
> >
> 


      

Re: QueryCacheImpl question

Posted by Jeremy Bauer <te...@gmail.com>.
Hi Mark,

OpenJPA has a query result cache (QueryCache) for caching full query results
and a SQL query cache (QuerySQLCache) for caching SQL queries. You've
disabled the QueryCache (which is actually disabled by default).  I believe
the bug you've hit is in the query SQL cache.  Try disabling the query SQL
cache via:

<property name="openjpa.jdbc.QuerySQLCache" value="false"/>

hth,
-Jeremy

On Tue, Oct 19, 2010 at 11:35 AM, Mark Struberg <st...@yahoo.de> wrote:

> Hi!
>
> I have a problem with upgrading from OpenJPA-2.0.0 to 2.0.1.
>
> One of my services executes the following query (this is the 'id' I get in
> PreparedQueryCacheImpl#get(String id) ):
>
> SELECT distinct e FROM Employment em, Person e WHERE em.employeeId =
> e.employeeId and em.orgUnitCode = :orgUnitCode AND em.employmentPosition in
> (:employmentPositions) AND em.start <= :startBefore AND em.end >= :endAfter
> ORDER BY e.familyName ASC
>
> Somehow when I execute my service a few times with different
> employmentPositions params (ArrayList<String>) I still get the 'old' cached
> param values!
>
> I tried to disable this behaviour in my persistence.xml with
>
>  <property name="openjpa.QueryCache" value="false"/>
>
> but this didn't work.
>
> Maybe this was a side effect of the ORDER BY which made this query work in
> 2.0.0 (caching of queries with ORDER BY got only fixed after 2.0.0), so I'd
> like to write a unit test for it.
> Imo it's not that easy to cache queries with a select IN, wdyt?
>
>
> keep u updated, but feel free to ping me if this is a known issue ...
>
> txs and LieGrue,
> strub
>
>
>
>