Re: how to clear cache

Armin Waibel <[email protected]> Tue, 25 Sep 2007 16:29:16 +0200
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hi Hans,

Hans Novak wrote:
> Hi Ng,
> 
> i use allesandros mandragora with ojb in "mixed-mode".
> It is working fine, but when i remove objects with mandragora and then 
> read the again with ojb, i get the cached object back, not the one, what 
> hase been saved.
> When i restart my app, then i get the right object.
> So, how can i clear the ob cache (or whatever, to get the right data :-) 
> ) ?

You can use

PersistenceBroker.clearCache();
to evict the whole cache

PersistenceBroker.serviceObjectCache().remove(Identity oid);
remove a specific object

Take care that all insert/update/delete operations are performed within 
a running transaction, else the cache will be corrupted.
Take care that mandragora use your current PB instance or get a new PB 
instance after using mandragora (to avoid session cache issues).

All "delete by query" stuff (PB.deleteByQuery) doesn't synchronize with 
the cache.

regards,
Armin

> 
> Hans
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
>