db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <Fisc...@seitenbau.net>
Subject RE: How to use Transaction without using java.util.Connection
Date Tue, 06 Jul 2004 09:55:27 GMT





Hi Arndt,

If you are using Transactions it is possible to have more than one
transaction open. It is not clear in all circumstances which transaction
should be used for saving an object, so for maximum flexibility the user
has to decide this by telling the object which transaction should be used
for saving.  In Torque, the object carrying this information is the
connection object which is passed to the save method.

Usually, if you are using transactions, you want to have exact control
which object is loaded/saved/deleted in which transaction, so I would
strongly recommend to stick with passing around the connection object.
If you dont want to do this, you can override the load, save, ... methods
in the Data classes to do the transaction handling in your data objects.
You would have to store the connection in a place where every other object
can gave access to this connection, i.e. in a static member variable of
some kind. Then, every Data object can have access to the transaction.
Note that this procedure is VERY dangerous if you care about thread safety
(e.g. in a web application).
If you do this, you would have to do override the above methods in every
data object you use. To avoid this, you can go and change the velocity
templates in the generator, to create the sort of code you want.

Hope that helps,

       Thomas

a.winter@telenet-ag.de schrieb am 06.07.2004 11:22:19:

> Hi,
>
> im trying to use Transactions with torque (3.1). At the moment I'm
passing
> each Object
> to save to or to retrieve from the DB the connection-object. That works
> fine, but it is not,
> what I want.
>
> What I want ist that every object saved, delete or retrieved within an
> begin transaction and
> an commit / rollback transaction uses automatically the transaction.
>
> Any help would be appreciated.
>
> Thanks,
> Arndt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message