Stephen Ting wrote:
You said you are using a cm-tx and you do only a return if something does not match. The container does not know about that and commitI didn't called the sessionContext.setRollbackOnly(). Simply I just call the return statement.
the tx after method return --> OJB commit dirty objects too.
If you want to rollback the tx use setRollbackOnly()
tx = odmg.currentTransaction(); broker = ((NarrowTransaction)tx).getBroker();
//update the changed document ((NarrowTransaction)tx).markDirty(document);
List origBlock = document.getLogPondBlockList(); if(origBlock != null){ Iterator orig = origBlock.iterator(); while(orig.hasNext()){ ((NarrowTransaction)tx).markDirty(orig.next()); } }
Collection existed = broker.getCollectionByQuery(query); LogPond dbLogPond = (LogPond)existed.iterator().next(); List dbBlock = dbLogPond.getLogPondBlockList(); if(dbBlock != null){ Iterator i = dbBlock.iterator(); while(i.hasNext()){ LogPondBlock dbLogPondBlock = (LogPondBlock)i.next();
if(document.getLogPondBlock(dbLogPondBlock) == null){ ((NarrowTransaction)tx).markDelete(orig.next());
}else{
===> getSessionContext().setRollbackOnly();
hmm, maybe I misunderstood your question.
regards, Armin
///error.. Can't delete this item ON EXIST OF THIS METHOD, I FOUND THAT THE ABOVE MARK
DIRTY STILL TAKE EFFECT
return;
}
}
}
Regards, Stephen
-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: 28 November 2003 16:17
To: OJB Users List
Subject: Re: Container managed Transaction
Hi Stephen,
Stephen Ting wrote:
Can i programatic rollback managed transaction in ODMG api?
I have the following challenge.
1. ((NarrowTransaction)tx).markDirty(document1); 2. ((NarrowTransaction)tx).markDirty(subDoc1); 3. ((NarrowTransaction)tx).markDelete(subDoc2);
In the above sequence, says I excute statement 1 and 2 successfully, before reaching statement 3 I detected some errors and need to exit the method and rollback. In my testing, the
SQL Statement in 1 and 2 will get excuted.
What do you do when the error was detected? Did you call sessionContext.setRollbackOnly() ? Could you post some pseudo code?
Normally 1 and 2 shouldn't be executed when all method calls made in a cm-tx.
regards, Armin
My question is can I rollback sql statement 1 and 2 and assume I didn't mark document1 and subDoc1?
Thanks
Regards, Stephen Ting
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
