Hi Rick,

Yes, it passes with latest 2.4.0-SNAPSHOT, and OpenJPA log file does not 
contain SQL queries while executing JPQL query for the second time.

So do you know when this fix will be available in stable versions? And for 
which stable versions?

Thanks,
Oleg

-----Original Message-----
From: Rick Curtis [mailto:curti...@gmail.com] 
Sent: Tuesday, May 27, 2014 5:12 AM
To: users
Subject: Re: Data cache does not work in OpenJPA 2.2.2

Does this test pass on trunk? This sounds pretty familiar to a change[1] that I 
put into trunk.

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


On Mon, May 26, 2014 at 9:11 AM, LYALIKOV, Oleg (Oleg) < 
oleg.lyali...@alcatel-lucent.com> wrote:

> Forgot to update project archive to successfully run in OpenJPA 2.0.0 
> - you need to not only change openjpa version in pom file but also add 
> property <property name="openjpa.RemoteCommitProvider" value="sjvm"/> 
> in persistence.xml file (and also use "-XX:-UseSplitVerifier" as 
> project configured to be compiled by jdk 7)
>
> Thanks,
> Oleg
>
> From: LYALIKOV, Oleg (Oleg)
> Sent: Monday, May 26, 2014 5:56 PM
> To: users@openjpa.apache.org
> Subject: Data cache does not work in OpenJPA 2.2.2
>
> Hello,
>
> I have a simple project with several entities and several relations (a 
> little more complex than trivial) and when I execute query "SELECT obj 
> FROM MyEntity obj" several times OpenJPA still executes SQL queries on 
> database to retrieve some data.
>
> Some details: here are entities (you can find full descriptions in the 
> attached project):
> Person 1->* DocumentBase
> Document 1->* Link1
> Document 1->* Link2
> and Document entity inherits from DocumentBase entity. All relations 
> are eager OneToMany.
>
> I create one Person with one Document which also has one Link1 and one
> Link2 objects. Then I execute query "SELECT DISTINCT obj FROM Person obj"
> twice and still OpenJPA executes SQL queries for the second time to 
> retrieve Document/Link1/Link2 data. It makes 2 SQL queries. If I use 
> following setting (which I primarily interested in):
> <property name="openjpa.jdbc.SubclassFetchMode" value="none"/> then 
> these queries are:
>
> SELECT t0.docName, t1.DOCUMENT_ID, t2.id
>     FROM Document t0 LEFT OUTER JOIN Document_Link1 t1 ON t0.id = 
> t1.DOCUMENT_ID
>         LEFT OUTER JOIN Link1 t2 ON t1.LINK1_ID = t2.id
>     WHERE t0.id = ?
>     ORDER BY t1.DOCUMENT_ID ASC
> [params=(String) 51]
>
> and
>
> SELECT t1.id
>     FROM Document_Link2 t0 INNER JOIN Link2 t1 ON t0.LINK2_ID = t1.id
>     WHERE t0.DOCUMENT_ID = ?
> [params=(String) 51]
>
> if I use default value for "openjpa.jdbc.SubclassFetchMode" property 
> then anyway 2 queries are executed:
>
> SELECT t1.id
>     FROM Document_Link1 t0 INNER JOIN Link1 t1 ON t0.LINK1_ID = t1.id
>     WHERE t0.DOCUMENT_ID = ?
> [params=(String) 51]
>
> and
>
> SELECT t1.id
>     FROM Document_Link2 t0 INNER JOIN Link2 t1 ON t0.LINK2_ID = t1.id
>     WHERE t0.DOCUMENT_ID = ?
> [params=(String) 51]
>
> If there are a lot of such objects and a lot of such relations then 
> application just spends all its time in database. It is serious 
> performance impact...
>
> There is junit test in the attached project which fails in OpenJPA 
> 2.2.2 and it passes in OpenJPA 2.0.0 so it looks like a regression.
>
> After some analysis it seems that the change was in 
> DataCacheStoreManager::load method. In the OpenJPA 2.0.0 the method 
> cacheStateManager is executed which properly put fully loaded objects 
> in cache while in OpenJPA 2.2.2 it firstly check CacheStoreMode, the 
> value is "USE", the objects are "alreadyCached" (they are actually in 
> cache but only partially loaded) and so OpenJPA does not update cache 
> and so only partially loaded objects are in cache and so OpenJPA 
> always executes SQL queries to complete these objects on every query.
>
> So should I post it as a bug in issue tracker? And also maybe you know 
> some workaround for this issue?
>
> Thanks,
> Oleg
>



--
*Rick Curtis*

Reply via email to