You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Boulay, Serge" <Se...@qunara.com> on 2002/11/29 22:55:22 UTC

ODMG Session Bean oc4j

I am using odmg session bean example packaged with the source distribution . It works well but I have one question . 
When I throw and EJBException , or even tx.currentTransaction.abort() only the last statement is aborted . I need an all or nothing principal to work
for me . 
 
The code is something like this 
 
Transaction tx = odmg.currentTransaction();
 
....
 
// Save new object to database
tx.lock(objectToInsert, Transaction.WRITE);
 
// Perform an update 
tx.lock(objectToUpdate, Transaction.UPGRADE);
object.setNextId(objectToInsert.getId());
 
throw new EJBException() -> or abort()
 
 
 
 
This code only rolls back the update and not the insert . I need it to rollback both .
Any solutions would help .
 
Thanks
 
Serge

Re: ODMG Session Bean oc4j

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Serge,

when call tx.lock(....) the objects will be collected within OJB,
there was no Database call, till the tx was commited by the container.
If you throw an EJBException or do abort all collected objects
will be discarded. So there shouldn't be any problems.
There are serveral rollback test cases all work fine.
When using a stateful session bean that keeps the modified
object, the modifications on the object will not be rolled back.
Maybe I don't understand the problem, maybe you could send a test
case to demonstrate the problem.


regards,
Armin


----- Original Message -----
From: "Boulay, Serge" <Se...@qunara.com>
To: <oj...@jakarta.apache.org>
Sent: Friday, November 29, 2002 10:55 PM
Subject: ODMG Session Bean oc4j


I am using odmg session bean example packaged with the source
distribution . It works well but I have one question .
When I throw and EJBException , or even tx.currentTransaction.abort()
only the last statement is aborted . I need an all or nothing principal
to work
for me .

The code is something like this

Transaction tx = odmg.currentTransaction();

....

// Save new object to database
tx.lock(objectToInsert, Transaction.WRITE);

// Perform an update
tx.lock(objectToUpdate, Transaction.UPGRADE);
object.setNextId(objectToInsert.getId());

throw new EJBException() -> or abort()




This code only rolls back the update and not the insert . I need it to
rollback both .
Any solutions would help .

Thanks

Serge