You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by "Boring, Jeff W (N-Viper)" <je...@lmco.com> on 2008/12/12 21:53:25 UTC

Does DataCache support RW (Infrequently)

If another app or user updates the db (via JPA), will those updates be
reflected in the DataCache?

 

I need to understand under what specific circumstances the cache would
not be updated. If changes are made to the db outside of JPA, via some
SQL tool then of course I know that the cache will not be aware of this.
(One could use timeout perhaps in this scenario.) But what does "inside
of JPA" mean exactly? Don't the updates have to be made by the same
EntityManagerFactory instance? 

 

Thanks for the help,

 

Jeff

 

 

Jeff W. Boring

Lockheed Martin

Orlando, Fl 32825



 


Re: Does DataCache support RW (Infrequently)

Posted by Fernando Padilla <fe...@alum.mit.edu>.
So there are various levels of cache.

L1 = Within one EntityManager
L2 = Within one EntityManagerFactory ( openjpa.DataCache=true)

The default DataCache implementation used by an EntityManagerFactory is 
essentially backed by a simple Map.  So if you have more than one 
EntityManagerFacotry ( within same JVM, or different ), each one 
maintains their own view of the Cache.

The way that they are kept in sync, is through the RemoveCommitEvents ( 
RemoteCommitProvider ).  Whenever any EntityManager commits something to 
the database, it announces that commit, and all caches listen for commit 
events and clear their ditry entries through using the RemoteCommitProvider.

So RremoteCommitProvider is an interface around some Messaging backbone 
to allow all caches to remain in sync.  The default RemoteCommitProvider 
is SJVM (Single JVM), which will only work for multiple 
EntityManagerFactories within the same JVM.  To be able to maintain 
caches/commits across JVMs, you need an enhanced RemoveCommitProvider. 
OpenJPA comes with a handle of them, but you can always make your own 
around your preferred Group Messaging Backbone, if you prefer. :)

I hope I have you a good intro.  Please review the 
DataCache/RemoveCommitProvider sections in the docs.. and see if that 
helps too:

http://openjpa.apache.org/builds/latest/docs/manual/manual.html




Sandhya Turaga wrote:
> Hi Jeff,
> 
>         When another app or transaction updates the database via JPA, those changes are reflected in the cache after the database commit. One Datacache map will be created per Persistence-unit and all the entities that are updated in that EntityManagerFactory/persistence-unit through the JPA are reflected in the cache. 
> 
> Hope this answers your question
> 
> Thanks
> Sandhya
> 
> --- On Fri, 12/12/08, Boring, Jeff W (N-Viper) <je...@lmco.com> wrote:
> From: Boring, Jeff W (N-Viper) <je...@lmco.com>
> Subject: Does DataCache support RW (Infrequently)
> To: users@openjpa.apache.org
> Date: Friday, December 12, 2008, 12:53 PM
> 
> If another app or user updates the db (via JPA), will those updates be
> reflected in the DataCache?
> 
>  
> 
> I need to understand under what specific circumstances the cache would
> not be updated. If changes are made to the db outside of JPA, via some
> SQL tool then of course I know that the cache will not be aware of this.
> (One could use timeout perhaps in this scenario.) But what does "inside
> of JPA" mean exactly? Don't the updates have to be made by the same
> EntityManagerFactory instance? 
> 
>  
> 
> Thanks for the help,
> 
>  
> 
> Jeff
> 
>  
> 
>  
> 
> Jeff W. Boring
> 
> Lockheed Martin
> 
> Orlando, Fl 32825
> 
> 
> 
>  
> 
> 
> 
> 
>       

Re: Does DataCache support RW (Infrequently)

Posted by Sandhya Turaga <tu...@yahoo.com>.
Hi Jeff,

        When another app or transaction updates the database via JPA, those changes are reflected in the cache after the database commit. One Datacache map will be created per Persistence-unit and all the entities that are updated in that EntityManagerFactory/persistence-unit through the JPA are reflected in the cache. 

Hope this answers your question

Thanks
Sandhya

--- On Fri, 12/12/08, Boring, Jeff W (N-Viper) <je...@lmco.com> wrote:
From: Boring, Jeff W (N-Viper) <je...@lmco.com>
Subject: Does DataCache support RW (Infrequently)
To: users@openjpa.apache.org
Date: Friday, December 12, 2008, 12:53 PM

If another app or user updates the db (via JPA), will those updates be
reflected in the DataCache?

 

I need to understand under what specific circumstances the cache would
not be updated. If changes are made to the db outside of JPA, via some
SQL tool then of course I know that the cache will not be aware of this.
(One could use timeout perhaps in this scenario.) But what does "inside
of JPA" mean exactly? Don't the updates have to be made by the same
EntityManagerFactory instance? 

 

Thanks for the help,

 

Jeff

 

 

Jeff W. Boring

Lockheed Martin

Orlando, Fl 32825