Hello Jair,

Automatically clearing the cache for the object touched by the aborted transaction may cause loss of data, let's say it so, if storing data to db fails due to a temporary db failure, then you will loose all the data you last entered (if you don't have them backed up in other value objects). So I would say that always and uncoditionally clearing the cache is not a good idea. However it would be very useful if the PersistenceBroker would have a method that allows to get the list of all affected persistent objects and let the user decide if they have to be removed from cache (ev. directly with another method call).

We also have the same problem, however because of the type of our object model (lot of interconnected hierarchic revisionable data) we work with auto-refresh and auto-update set to false, so we have to update all relationships by hand. This way we always know wich objects are affected, before every call to pb.store( obj ), we just put obj in a 'rollback'-list, if the transaction is aborted we remove from cache all object available in our 'rollback'-list.

If somebody has a better solution, just tell me...

bye
danilo

Hi,
    Thank you Mahler for your fast reply.
    I understand that it is not possible to do it with the current OJB API.
    I am asking you this because I need to remove from OJB cache the objects
touched by a transaction when it is aborted.
    Here is what I think could be a good idea to fix this issue: as noted in
the OJB cache documentation (http://db.apache.org/ojb/objectcache.html), the
OJB user must manually remove each object touched by the trasaction when
using ObjectCacheDefaultImpl and the transaction is aborted because the
objects may be corrupted. So why doesn't the implementation of the
Transaction.abort method removes the touched objets from the cache? I think
this should fix this issue, don't you?
    Well, it's just an idea. In my system I am going to remove the objects
from cache manually, but as there's no way to get only the objects touched
by the transaction I'll have to clear the entire cache.

Thanks,
Jair Jr

----- Original Message -----
From: "Mahler Thomas" <[EMAIL PROTECTED]>
To: "'OJB Users List'" <[EMAIL PROTECTED]>
Sent: Tuesday, October 28, 2003 1:45 PM
Subject: RE: how to get objects locked by a transaction?



Hello Jair,

OJB ODMG stores each registered Objects in an o.a.ojb.odmg.ObjectEnvelope.
All ObjectEnvelopes are kept in an o.a.ojb.odmg.ObjectEnvelopeTable.
ObjectEnvelopeTable has a public method
public Enumeration elements();

which returns an Enumeration of all ObjectEnvelopes.

The each OJB ODMG TransactionImpl maintains its own ObjectEnvelopeTable:
   /**
    * the internal table containing all Objects "touched" by this tx and
their
    * respective transactional state
    */
   private ObjectEnvelopeTable objectEnvelopeTable = null;

Currently TransactionImpl does not provide public access to the
ObjectEnvelopeTable.
So I don't see a way to perform your task without changing OJB code...

cheers,
Thomas


-----Original Message-----
From: Jair da Silva Ferreira Júnior [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 28, 2003 12:25 AM
To: OJB Users List
Subject: how to get objects locked by a transaction?


Hello, How can I safely get all objects locked by a transaction using ODMG or broker API? I need this because I want to remove all objects locked by a transaction from the cache. Something like this:

       .....
       Iterator lockedObjects=getLockedObjects(transaction);
       while(lockedObjects.hasNext()){
           broker.removeFromCache(lockedObjects.next());
       }
       .....

Thanks,
   Jair Jr



---------------------------------------------------------------------
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]



--
Danilo Tommasina, Dipl. Ing. FH Telecom
Software Engineer
RCS Riskmanagement Concepts Systems AG
Technoparkstrasse 1
CH-8005 Zuerich
T: +41 1 445 29 08
[EMAIL PROTECTED]
www.risksys.com


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



Reply via email to