Hi Thomas,

Correct me please if I am wrong, ObjectEnvelopeTable and related cache cleaning on abort-transaction is an ODMG feature. The PersistenceBroker API does not offer this feature, so the documentation at http://db.apache.org/ojb/objectcache.html is correct (maybe a little out of date), it is also possible to just call pBroker.removeFromCache( obj ) to do the same job in a more compact way :)

cheers
danilo



Hi Jair,



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?


That's already implemented!
The ObjectENvelopeTable.rollback() method performs rollback actions for all
registered objects.

public void rollback()
{
PersistenceBroker broker = transaction.getBroker();
Iterator iter = mvOrderOfIds.iterator();
while (iter.hasNext())
{
ObjectEnvelope mod = (ObjectEnvelope)
mhtObjectEnvelopes.get(iter.next());
if (log.isDebugEnabled())
log.debug("rollback: " + mod);
// if the Object has been modified has been modified by
transaction, mark object as dirty
if (mod.hasChanged())
{
mod.setModificationState(mod.getModificationState().markDirty());
}
mod.getModificationState().rollback(mod, broker);
}
}


The ModificationState.rollback(...) calls remove dirty instances from the
cache.
For example the StateOldDirty.rollback method looks like follows:
    public void rollback(ObjectEnvelope mod, PersistenceBroker broker)
    {
        this.removeFromCache(mod.getObject(), broker);
        // Call added to rollback the object itself so it has the previous
values again when it is used further on.
        mod.rollback();
    }

clean Objects (that is Objects not modified during the transaction) will not
be removed from the cache!



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.


I thinks that's not necessary, given my above explanation.

cheers,
thomas


Thanks,
Jair Jr


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



Reply via email to