>3. you can use the PerBrokerCache so that changes to cached objects are
only visible within one thread.

I don't seem to be able to find PerBrokerCache. What is the consequence of
the cached objects being only visible within one thread ?

>By default OJB uses a global cache, so changes to any cached objects are
visible across the whole JVM.

What if I use the OJB in server mode with a multiuser environment ?


Regards,

Patrick Reyes


                                                                                       
                            
                    Thomas Mahler                                                      
                            
                    <[EMAIL PROTECTED]       To:     OJB Users List <[EMAIL 
PROTECTED]>                           
                    >                    cc:     (bcc: Patrick Reyes/CDS/CG/CAPITAL)   
                            
                    Sent by:             Subject:     Re: Cache question               
                            
                    [EMAIL PROTECTED]                                                  
                                
                                                                                       
                            
                                                                                       
                            
                    06/03/2003                                                         
                            
                    10:51 AM                                                           
                            
                    Please respond                                                     
                            
                    to "OJB Users                                                      
                            
                    List"                                                              
                            
                                                                                       
                            
                                                                                       
                            




Hi Patrick,

[EMAIL PROTECTED] wrote:
> Hi guys, I am quite sure this is the right behavior of the cache, but I
> would like some clarifications.
>
> 1) I read the content of a table and store the corresponding objects in a
> Collection.
> 2) I update the content of the objects.
> 3) I re-read the content of the table without updating the modified
object.
> 4) Instead of replacing the content of the updated object with the
content
> stored in the database, the updated object is retrieved a such with its
> modifications.
>
> My questions are:
>
> 1) Is this due to the internal cache ?

Exactly! If you perform any OJB query, OJB will first check if a result
object is already cached. If so, the cached version is returned.
(even when the cached object is dirty (i.e. contains uncommitted changes))!

> 2) How can I ask OJB to retrieve only comitted changes from the database
?

1. you can call broker.clearCache() to empty the cache before performing
a query.
2. you can also set the class-descriptor attribute refresh="true" this
will advise OJB to always load instances of a given class from the db
and not from the cache.
3. you can use the PerBrokerCache so that changes to cached objects are
only visible within one thread.

> 3) If I use a muti-user environnment will each user get the same copy of
> the object (i.e. the updated one) even if I have still not store the
object
> ?

By default OJB uses a global cache, so changes to any cached objects are
visible across the whole JVM.
You should use the PerBrokerCache in a multi user / multi thread
environment to change this behaviour. See OJB.properties for details.

> 4) Does this behavior have anything to do with the optimistic caching ?

You mean Optimistic Locking? Not really. It's just Global vs. Local cache.

cheers,
Thomas

>
> Thanks and regards,
>
> Patrick Reyes
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to