Small suggestion - method for checking if a DB transaction is in progress

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Small suggestion - method for checking if a DB transaction is in progress

stefcl
Hello,

I wonder if it would be possible to add a method to SqlSession that would tell if a database transaction has been started or not.
Something like :

boolean SqlSession.isTransactionInProgress()

It would allow a method that receives the SqlSession in parameter to know if the caller has already started a transaction. Based upon that information, the method could decide either to start a transaction (that it would commit before returning) or use the active one.

I think it could be useful in scenarios where AOP frameworks can't be used.
Kind regards
Reply | Threaded
Open this post in threaded view
|

Re: Small suggestion - method for checking if a DB transaction is in progress

Clinton Begin
In iBATIS 3, the SqlSession is the transaction.  So if you have one, you're in a transaction.  The one exception is if you create a SqlSession in auto-commit mode, which is not in a transaction, but also cannot be turned into a transaction.  Thus it would be irrelevant.

Clinton

On Wed, Jan 6, 2010 at 1:04 AM, stefcl <[hidden email]> wrote:

Hello,

I wonder if it would be possible to add a method to SqlSession that would
tell if a database transaction has been started or not.
Something like :

boolean SqlSession.isTransactionInProgress()

It would allow a method that receives the SqlSession in parameter to know if
the caller has already started a transaction. Based upon that information,
the method could decide either to start a transaction (that it would commit
before returning) or use the active one.

I think it could be useful in scenarios where AOP frameworks can't be used.
Kind regards
--
View this message in context: http://old.nabble.com/Small-suggestion---method-for-checking-if-a-DB-transaction-is-in-progress-tp27026807p27026807.html
Sent from the iBATIS - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Small suggestion - method for checking if a DB transaction is in progress

stefcl
Right...
Actually, it seems that I was mixing elements from v2 and v3 APIs. My bad...
Sorry!

Clinton Begin wrote
In iBATIS 3, the SqlSession is the transaction.  So if you have one, you're
in a transaction.  The one exception is if you create a SqlSession in
auto-commit mode, which is not in a transaction, but also cannot be turned
into a transaction.  Thus it would be irrelevant.

Clinton

On Wed, Jan 6, 2010 at 1:04 AM, stefcl <stefatwork@gmail.com> wrote:

>
> Hello,
>
> I wonder if it would be possible to add a method to SqlSession that would
> tell if a database transaction has been started or not.
> Something like :
>
> boolean SqlSession.isTransactionInProgress()
>
> It would allow a method that receives the SqlSession in parameter to know
> if
> the caller has already started a transaction. Based upon that information,
> the method could decide either to start a transaction (that it would commit
> before returning) or use the active one.
>
> I think it could be useful in scenarios where AOP frameworks can't be used.
> Kind regards
> --
> View this message in context:
> http://old.nabble.com/Small-suggestion---method-for-checking-if-a-DB-transaction-is-in-progress-tp27026807p27026807.html
> Sent from the iBATIS - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: dev-help@ibatis.apache.org
>
>