Thought inc.

The Dynamic O/R Mapping Company
     

CocoBase Technical Support Forums
For access to developer site with software download and doc's, please request CocoBase download and password
will be emailed to you. Response to posts will appear when answered by THOUGHT Support team.
NOTE:You must register separately with forum in order to post your questions, please click on register icon below.
Home   Frequently Asked Questions   Search   Edit your profile   Registration is free!  
Email This Page to Someone!
Show a Printable Version
CocoBase Enterprise O/R Forums > CocoBase Bug Reports
Global Transaction Stack
< Previous Thread     Next Thread >
Author
Thread    Post New Thread     Post A Reply
Ed Ward
Member

Registered: Feb 2002
Posts: 2

The following problems relate to CocoBase version 4.0. I do not know if they are present in other versions.

I have found what seem to be bugs, or at least inconsistant behaviour, when using global Transaction instances. The problems relate specifically to the static Stack of 'global' transactions and therefore are not present with 'local' transactions. The reason I am interested in global transactions is that I need to use the TransactionFactory to bind new factory instances to the current transaction.

problem1:

Transaction txn = Transaction.getTransaction();
// Okay. txn == null (no transaction in progress)
Transaction txn2 = new Transaction(myBase, true);
txn = Transaction.getTransaction();
// Okay. txn == txn2 (the latest global transaction)
txn2.begin();
.... create / delete / update objects etc.
txn2.commit();
txn2.close();
txn = Transaction.getTransaction();
// Not okay. I would have expected 'txn' to be equal
// to null since there is no transaction (the only
// transaction has now been closed). 'txn' in fact
// still refers to the transaction that was created
// above. A call to txn.isOpen() returns true!


problem2:

Transaction txnOne = new Transaction(myBase, true);
txnOne.begin();

Transaction txnTwo = new Transaction(myBase, true);
txnTwo.begin();
txnTwo.commit();
txnTwo.close();

txnOne.commit();
txnOne.close();

int numberOfActiveTransactions = Transaction.transactionStack.size();
int numberOfActiveTransactions = Transaction.transactionStack.size();
// I would expect numberOfActiveTransactions to be zero,
// but the value is in fact 1


problem3: (similar to problem 2 above but a different result)

Transaction txnOne = new Transaction(myBase, true);

Transaction txnTwo = new Transaction(myBase, true);
txnOne.begin(); // <-- moved after the creation of the second transaction

txnTwo.begin();
txnTwo.commit();
txnTwo.close();

txnOne.commit();
txnOne.close();

int numberOfActiveTransactions = Transaction.transactionStack.size();
int numberOfActiveTransactions = Transaction.transactionStack.size();
// I would expect numberOfActiveTransactions to be zero,
// but the value is now 2


The javadoc documentation for the method Transaction.close() states "This will close the transaction object, and remove this Transaction from the global 'active' transaction list."

02-21-2002 08:52 AM
Click Here to See the Profile for Ed Ward    Find more posts by Ed Ward        Edit/Delete Message    Reply w/Quote    IP: Logged
admin
Administrator

Registered: Apr 2001
Posts: 19

Generally speaking don't use the Global Transaction stack.

There are some app server/thread context issues with it, and
you should always use it in instance mode as a rule of thumb.

The Global is for backward compatibility, and it can require
quite a bit of effort to debug application code, etc. to make
it work properly...

THOUGHT Support

02-22-2002 11:13 AM
Click Here to See the Profile for admin    Find more posts by admin        Edit/Delete Message    Reply w/Quote    IP: Logged
All times are PST (US)    Post New Thread     Post A Reply
Forum Jump:
< Previous Thread     Next Thread >

Forum Rules:
Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author. Messages can be deleted by their author.
Posts: HTML code is OFF. Smilies are OFF. vB code is OFF. [IMG] code is OFF.

Admin Options:
Open / Close Thread
Move Thread
Delete Thread
Edit Thread

< Contact Us - THOUGHT Inc. >

Copyright © Jelsoft Enterprises Limited 2000.
Copyright 2001 All Rights Reserved, THOUGHT Inc.