[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: transaction puzzle

On Wed, 16 May 2001, skyin wrote:
> hi all

>   i am new to Ozone community recently. i have install, compile, run the
example and see the tut and the doc on the site. it's really a wonderful work
in the open-source world!!

>   but i am puzzled about the ozone's definition of "transaction". in the
"user documentation", it says that "each client side invocation of a proxy
method creates a new transaction." and "put the code that should run iside one
transaction inside one database object method". it's clear. but in the tut, the
instruction followed "The GarageApp.java program" says that "In our example we
iterate over a collection of objects. Of course this should be a transaction
because we do not want the GarageImpl object to be changed while we are working
with it".

> thus, according the former definition, in the 'oldtimer' section,

> "Vector oldtimers = garage.oldtimers();" is a transaction
> "car.name()" and "car.age()" is another two transaction

> do i understand right? but according to the latter,how to avoid GarageImp
> object to be changed during the time between these transaction in "oldtimer"
> section? i mean if the client-side "oldtimer" section is also a transaction
> process to avoid that thing?

You are right, nothing prevents the oldtimers to be changed in between the
oldtimers() and the name()/age() calls. If another client is expected to change
the oldtimers, then all three methods should run inside one transaction. This
can be done via explicite tx demarcation on the client:

	ExternalTransaction tx = db.newTransaction()
	try {	
	} catch (Exception e) {

Sometimes one simply cannot avoid explicite tx demarcation. But you should
always try to.

Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com