This one time, at band camp, Venkat Dosapati said:

VD>how can I achieve flat transaction support with Castor JDO?
VD>See the below classes:
VD>- ClassA.methodA() gets Database and begins transaction,
VD>   updates DB, calls ClassB.methodB(), updates DB, then commits
VD>  sequentially.
VD>- ClassB.methodB() gets Database, begins transaction, updates DB,
VD>  commits.
VD>
VD>My question is here: when some exception occured in ClassA.methodA()
VD>after completion of ClassA.MethodA(), in the try-catch block, the
VD>transaction
VD>is getting rollback(). when this happens the changes occured in
VD>ClassA.methodA()
VD>should be rolled back. which is not happening now with Castor JDO.
VD>
VD>Am I missing anything?
VD>
VD>
VD>Class A {
VD>    public void methodA() {
VD>
VD>        Database db = null;
VD>        try {
VD>        _jdo.getDatabase();
VD>        db.begin();
VD>            // statements for updating  jdo objects using OQL
VD>
VD>            /* call is made to ClassB.methodB */
VD>            (new ClassB()).methodB();
VD>
VD>            // statements for updating jdo objects using OQL
VD>        db.commit();
VD>        db.close();
VD>        }catch(Exception ex) {
VD>            db.rollback();  // this should rollback all the updates within
VD>this method and in ClassB.methodB() method.
VD>            db.close();
VD>        }
VD>    }
VD>}
VD>
VD>Class B {
VD>    public void methodB() {
VD>        Database db = _jdo.getDatabase();
VD>        db.begin();
VD>            // statements for updating
VD>        db.commit();
VD>        db.close();
VD>
VD>    }
VD>}

Venkat,

I think I understand the problem, but let me restate it just to be sure. 

An exception is occurs in the methodA() and you're expecting changes from
methodB() to be rolled back by methodA()'s call to rollback. Is that correct. 

If this is the question you are asking, Castor JDO will not handle
that situation in a 'flattening' of the two transactions into one. The
reason for this is that the changes made in methodB() are governed by
a completely separate transactional context. The transaction used in
methodA() has no knowledge of the changes made to objects in methodB()'s
transaction. Those two transactions are completely separate.

Bruce
-- 
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

The Castor Project 
http://www.castor.org/

Apache Geronimo 
http://incubator.apache.org/projects/geronimo.html

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to