You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Rick Curtis (JIRA)" <ji...@apache.org> on 2010/02/15 17:21:27 UTC

[jira] Created: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Executing a cached query doesn't properly cache results after DataCache eviction
--------------------------------------------------------------------------------

                 Key: OPENJPA-1511
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 2.0.0-beta
            Reporter: Rick Curtis
         Attachments: TestCache.java

When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 

I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.

The test scenario is as follows:

String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
items = em.createQuery(query,Item.class).getResultList();
assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
// Make sure that all of the results are in the DataCache.
for(Item o : items){
  assertTrue(storeCache.contains(Item.class, o.getId()));
}
storeCache.evict(Item.class,items.get(0).getId());
// Evict one result
assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
        
// Executing the same query should re-populate the datacache
items = em.createQuery(query,Item.class).getResultList();
assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by Kevin Sutter <kw...@gmail.com>.
For historical reasons, I think this discussion needs to be in the JIRA...
But, I'll let one you to summarize and get the JIRA updated appropriately...

Given the additional description of the scenario, I also question the
validity of the scenario.  We should only update the L2 cache upon a commit
or a re-read from the database (going to and from the database).  Expecting
dangling L1 entities to automatically populate the L2 cache is beyond the
scope of the cache capability (IMHO).

So, what if we modify the scenario and use Ravi's suggestion of evicting
both the L1 and L2 items.  Then, when accessing the query results, we should
have to go against the database and get the L2 cache re-populated.  I'm
assuming this works correctly...

Kevin

On Wed, Mar 3, 2010 at 10:42 AM, Rick Curtis <cu...@gmail.com> wrote:

> The more I think about this, the more unsure I am of what the correct
> answer
> is. Perhaps someone else on the dev list has some input?
>
> Is the test that I've posted to OPENJPA-1511 a valid test?
>
> --
> Thanks,
> Rick
>
> On Wed, Mar 3, 2010 at 10:32 AM, Ravi Palacherla <
> ravi.palacherla@oracle.com
> > wrote:
>
> > Hi Rick,
> >
> > I have a question about the following comment:
> >  >> * Execute a cached query which will return [E1]. This *should* result
> > in [E1] being placed back in the L2 cache, but it isn't.
> >
> > When [E1] is in L1cache then what is the need to check L2 cache ?
> >
> > It is only when [E1] is missing in L1cache is when it tries to fetch from
> > L2cache.
> > At this time as L2cache does not contain [E1] it goes to DB and
> re-populate
> > L2cache with [E1].
> >
> > Regards,
> > Ravi.
> >
> > -----Original Message-----
> > From: Rick Curtis (JIRA) [mailto:jira@apache.org]
> > Sent: Wednesday, March 03, 2010 8:32 AM
> > To: dev@openjpa.apache.org
> > Subject: [jira] Commented: (OPENJPA-1511) Executing a cached query
> doesn't
> > properly cache results after DataCache eviction
> >
> >
> >    [
> >
> https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840696#action_12840696
> ]
> >
> > Rick Curtis commented on OPENJPA-1511:
> > --------------------------------------
> >
> > I don't think that calling Cache.evict() should also remove an Entity
> from
> > the L1 cache. The javadoc for javax.persistence.Cache.evict(..) doesn't
> > mention anything about removing the provided Entity from the persistence
> > context.
> >
> > I think the problem here is as follows:
> > * Entity [E1] is in the L2 cache and is managed by the current
> persistence
> > context (L1 cache).
> > * Evict [E1] from the L2 cache. [E1] is still in the L1 cache.
> > * Execute a cached query which will return [E1]. This *should* result in
> > [E1] being placed back in the L2 cache, but it isn't.
> >
> > Make sense?
> >
> > > Executing a cached query doesn't properly cache results after DataCache
> > eviction
> > >
> >
> --------------------------------------------------------------------------------
> > >
> > >                 Key: OPENJPA-1511
> > >                 URL:
> https://issues.apache.org/jira/browse/OPENJPA-1511
> > >             Project: OpenJPA
> > >          Issue Type: Bug
> > >    Affects Versions: 2.0.0-beta
> > >            Reporter: Rick Curtis
> > >            Assignee: Ravi P Palacherla
> > >         Attachments: TestCache.java
> > >
> > >
> > > When doing some testing I found that the QueryCache sometimes doesn't
> put
> > results into the DataCache.
> > > I haven't had time to debug the problem, but I'm opening this JIRA so I
> > can attach the test case I've created.
> > > The test scenario is as follows:
> > > String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> > > items = em.createQuery(query,Item.class).getResultList();
> > > assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> > > // Make sure that all of the results are in the DataCache.
> > > for(Item o : items){
> > >   assertTrue(storeCache.contains(Item.class, o.getId()));
> > > }
> > > storeCache.evict(Item.class,items.get(0).getId());
> > > // Evict one result
> > > assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
> > >
> > > // Executing the same query should re-populate the datacache
> > > items = em.createQuery(query,Item.class).getResultList();
> > > assertTrue(storeCache.contains(Item.class, items.get(0).getId())); //
> > fails here
> >
> > --
> > This message is automatically generated by JIRA.
> > -
> > You can reply to this email to add a comment to the issue online.
> >
> >
>

Re: [jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by Rick Curtis <cu...@gmail.com>.
The more I think about this, the more unsure I am of what the correct answer
is. Perhaps someone else on the dev list has some input?

Is the test that I've posted to OPENJPA-1511 a valid test?

-- 
Thanks,
Rick

On Wed, Mar 3, 2010 at 10:32 AM, Ravi Palacherla <ravi.palacherla@oracle.com
> wrote:

> Hi Rick,
>
> I have a question about the following comment:
>  >> * Execute a cached query which will return [E1]. This *should* result
> in [E1] being placed back in the L2 cache, but it isn't.
>
> When [E1] is in L1cache then what is the need to check L2 cache ?
>
> It is only when [E1] is missing in L1cache is when it tries to fetch from
> L2cache.
> At this time as L2cache does not contain [E1] it goes to DB and re-populate
> L2cache with [E1].
>
> Regards,
> Ravi.
>
> -----Original Message-----
> From: Rick Curtis (JIRA) [mailto:jira@apache.org]
> Sent: Wednesday, March 03, 2010 8:32 AM
> To: dev@openjpa.apache.org
> Subject: [jira] Commented: (OPENJPA-1511) Executing a cached query doesn't
> properly cache results after DataCache eviction
>
>
>    [
> https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840696#action_12840696]
>
> Rick Curtis commented on OPENJPA-1511:
> --------------------------------------
>
> I don't think that calling Cache.evict() should also remove an Entity from
> the L1 cache. The javadoc for javax.persistence.Cache.evict(..) doesn't
> mention anything about removing the provided Entity from the persistence
> context.
>
> I think the problem here is as follows:
> * Entity [E1] is in the L2 cache and is managed by the current persistence
> context (L1 cache).
> * Evict [E1] from the L2 cache. [E1] is still in the L1 cache.
> * Execute a cached query which will return [E1]. This *should* result in
> [E1] being placed back in the L2 cache, but it isn't.
>
> Make sense?
>
> > Executing a cached query doesn't properly cache results after DataCache
> eviction
> >
> --------------------------------------------------------------------------------
> >
> >                 Key: OPENJPA-1511
> >                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
> >             Project: OpenJPA
> >          Issue Type: Bug
> >    Affects Versions: 2.0.0-beta
> >            Reporter: Rick Curtis
> >            Assignee: Ravi P Palacherla
> >         Attachments: TestCache.java
> >
> >
> > When doing some testing I found that the QueryCache sometimes doesn't put
> results into the DataCache.
> > I haven't had time to debug the problem, but I'm opening this JIRA so I
> can attach the test case I've created.
> > The test scenario is as follows:
> > String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> > items = em.createQuery(query,Item.class).getResultList();
> > assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> > // Make sure that all of the results are in the DataCache.
> > for(Item o : items){
> >   assertTrue(storeCache.contains(Item.class, o.getId()));
> > }
> > storeCache.evict(Item.class,items.get(0).getId());
> > // Evict one result
> > assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
> >
> > // Executing the same query should re-populate the datacache
> > items = em.createQuery(query,Item.class).getResultList();
> > assertTrue(storeCache.contains(Item.class, items.get(0).getId())); //
> fails here
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>

RE: [jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by Ravi Palacherla <ra...@oracle.com>.
Hi Rick,

I have a question about the following comment:
 >> * Execute a cached query which will return [E1]. This *should* result in [E1] being placed back in the L2 cache, but it isn't.

When [E1] is in L1cache then what is the need to check L2 cache ?

It is only when [E1] is missing in L1cache is when it tries to fetch from L2cache.
At this time as L2cache does not contain [E1] it goes to DB and re-populate L2cache with [E1].

Regards,
Ravi.

-----Original Message-----
From: Rick Curtis (JIRA) [mailto:jira@apache.org] 
Sent: Wednesday, March 03, 2010 8:32 AM
To: dev@openjpa.apache.org
Subject: [jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction


    [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840696#action_12840696 ] 

Rick Curtis commented on OPENJPA-1511:
--------------------------------------

I don't think that calling Cache.evict() should also remove an Entity from the L1 cache. The javadoc for javax.persistence.Cache.evict(..) doesn't mention anything about removing the provided Entity from the persistence context.

I think the problem here is as follows:
* Entity [E1] is in the L2 cache and is managed by the current persistence context (L1 cache).
* Evict [E1] from the L2 cache. [E1] is still in the L1 cache.
* Execute a cached query which will return [E1]. This *should* result in [E1] being placed back in the L2 cache, but it isn't.

Make sense?

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12838424#action_12838424 ] 

Rick Curtis commented on OPENJPA-1511:
--------------------------------------

I found that this is only a problem when the Entity that is evicted from the L2 cache still exists in the L1 cache.

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ravi P Palacherla reassigned OPENJPA-1511:
------------------------------------------

    Assignee: Ravi P Palacherla

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840818#action_12840818 ] 

Ravi P Palacherla commented on OPENJPA-1511:
--------------------------------------------

>> * Execute a cached query which will return [E1]. This *should* result in [E1] being placed back in the L2 cache, but it isn't. 

When [E1] is in L1cache then I think there is no need to check L2 cache ?

It is only when [E1] is missing in L1cache is when it tries to fetch  from L2cache.
 At this time as L2cache does not contain [E1] it goes to DB and re-populate L2cache with [E1].


> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis closed OPENJPA-1511.
--------------------------------

    Resolution: Invalid

After a few other JIRAs I understand this area of the code much better and I think everything is working as expected.

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis updated OPENJPA-1511:
---------------------------------

    Attachment: TestCache.java

Attaching test case.

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840820#action_12840820 ] 

Ravi P Palacherla commented on OPENJPA-1511:
--------------------------------------------

Adding the Dev mailing list conversation for historical reasons.

Kevin Sutter's comment on this issue:
--------------------------------------------------
" We should only update the L2 cache upon a commit or a re-read from the database (going to and from the database).  Expecting dangling L1 entities to automatically populate the L2 cache is beyond the scope of the cache capability (IMHO).

So, what if we modify the scenario and use Ravi's suggestion of evicting both the L1 and L2 items.  Then, when accessing the query results, we should have to go against the database and get the L2 cache re-populated.  I'm assuming this works correctly...

Kevin
"

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840696#action_12840696 ] 

Rick Curtis commented on OPENJPA-1511:
--------------------------------------

I don't think that calling Cache.evict() should also remove an Entity from the L1 cache. The javadoc for javax.persistence.Cache.evict(..) doesn't mention anything about removing the provided Entity from the persistence context.

I think the problem here is as follows:
* Entity [E1] is in the L2 cache and is managed by the current persistence context (L1 cache).
* Evict [E1] from the L2 cache. [E1] is still in the L1 cache.
* Execute a cached query which will return [E1]. This *should* result in [E1] being placed back in the L2 cache, but it isn't.

Make sense?

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1511) Executing a cached query doesn't properly cache results after DataCache eviction

Posted by "Ravi P Palacherla (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840480#action_12840480 ] 

Ravi P Palacherla commented on OPENJPA-1511:
--------------------------------------------

Currently there is a way to evict L2Cache when an entity is evicted from L1Cache.
It is achieved by  calling:
EntityManagerImpl.evict(entity) with property 
<property name="openjpa.BrokerImpl" value="EvictFromDataCache=true"/>
The above will make sure that evicting an entity from L1cache will also be evicted form L2cache.

The reverse is not defined anywhere  in openJPA docs and I think the reverse is what is needed as part of this JIRA.

I do not think it is possible (with my limited knowledge) because of the following reason:
In your testcase you are doing an evict from L2cache. Now the same entity in L2Cache can be shared by multiple L1cache's.
So an evict from L2cache should be able to find all the L1cache's that share this entity and should be evicted from all these L1cache's.
I do not think something like this is possible as I may not be able to get to L1cache (entityManager) from L2cache.

Please let me know if you disagree with any of the above.

Regards,
Ravi.

> Executing a cached query doesn't properly cache results after DataCache eviction
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1511
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1511
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta
>            Reporter: Rick Curtis
>            Assignee: Ravi P Palacherla
>         Attachments: TestCache.java
>
>
> When doing some testing I found that the QueryCache sometimes doesn't put results into the DataCache. 
> I haven't had time to debug the problem, but I'm opening this JIRA so I can attach the test case I've created.
> The test scenario is as follows:
> String query = "Select t FROM Item t where 1=1 ORDER BY t.id";
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId()));
> // Make sure that all of the results are in the DataCache.
> for(Item o : items){
>   assertTrue(storeCache.contains(Item.class, o.getId()));
> }
> storeCache.evict(Item.class,items.get(0).getId());
> // Evict one result
> assertFalse(storeCache.contains(Item.class,items.get(0).getId()));
>         
> // Executing the same query should re-populate the datacache
> items = em.createQuery(query,Item.class).getResultList();
> assertTrue(storeCache.contains(Item.class, items.get(0).getId())); // fails here

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.