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 "Robert S. Sfeir" <ro...@codepuccino.com> on 2003/11/19 01:13:56 UTC

Transaction blocks in selects

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, I was looking at the examples in the tutorial and it seems that even
for doing a select, which is not going to be followed by an update or
delete, OJB seems to indicate that we need to do:

tx.begin();
... do select stuff here
tx.commit();

However I tested this with no begin and commit blocks and it seems to
work fine, as I would expect.  In JDBC one never really does any kind of
transactions when doing selects only.  Is there a reason why we need to
begin and end a transaction in selects?  Doesn't that also affect
performance?

Thanks
R
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/urXE+cV9vuB27SARAmoPAKC2TUGr2hmrihRDFuE16xb20YjXLQCdGQHM
VqUOPxuRdnoR1iYyEF/+fxo=
=BFoe
-----END PGP SIGNATURE-----


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


Re: Transaction blocks in selects

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

Robert S. Sfeir wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi, I was looking at the examples in the tutorial and it seems that even
> for doing a select, which is not going to be followed by an update or
> delete, OJB seems to indicate that we need to do:
> 
> tx.begin();
> ... do select stuff here
> tx.commit();
> 
> However I tested this with no begin and commit blocks and it seems to
> work fine, as I would expect.  In JDBC one never really does any kind of
> transactions when doing selects only.  Is there a reason why we need to
> begin and end a transaction in selects?  Doesn't that also affect
> performance?
> 
It is save to do read-only operations without
ojb-tx-demarcation. The difference is if you
do the tx-declaration OJB knows that on tx.commit()
the obtained connection can returned to connection-pool.
obj-tx-demarcation is not very costly, the main thing is
to change the autoCommit flag of the connection and to
notify registered listeners.

Without tx-demarcation the association between PB instance
and the connection (via ConnectionManager) is not split
(till next tx.commit()/tx.abort or PB.close()).

It's on my todo list to make PB smart enough to
release connection after a read-only operation
when no tx is running.

If you using CVS head you can find a brand new PB-api
tutorial (pb-tutorial) written by Brian.

regards,
Armin


> Thanks
> R
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQE/urXE+cV9vuB27SARAmoPAKC2TUGr2hmrihRDFuE16xb20YjXLQCdGQHM
> VqUOPxuRdnoR1iYyEF/+fxo=
> =BFoe
> -----END PGP SIGNATURE-----
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 



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