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 > > ----- 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] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]