You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Clinton Begin <cl...@gmail.com> on 2009/11/10 16:26:22 UTC

Re: Potential connection problem when using managed transactions in iBATIS 3

That is a little odd.  It looks like I intended for something else there.
I'll look at it.

Clinton

On Tue, Nov 10, 2009 at 8:09 AM, Poitras Christian <
Christian.Poitras@ircm.qc.ca> wrote:

>  What is the expected behaviour when calling dataSouce.getConnection() for
> managed transactions in iBATIS 3?
>
> I find suspicious that ResultLoader calls dataSouce.getConnection() at line
> 89 which could create an unexpected connection. And since managed
> transaction is used, the connection may never be closed.
>
>
> Christian
>
>
> Here is the code from ResultLoader which calls dataSouce.getConnection() :
>
> *private* Executor newExecutor() *throws* SQLException {
>
> Environment environment =
> configuration.getEnvironment();
>
> *if* (environment == *null*)
>
> *throw* *new* ExecutorException("ResultLoader could not load lazily.
> Environment was not configured.");
>
> TransactionFactory txFactory = environment.getTransactionFactory();
>
> *if* (txFactory == *null*)
>
> *throw* *new* ExecutorException("ResultLoader could not load lazily.
> Transaction Factory was not configured.");
>
> DataSource ds = environment.getDataSource();
>
> *if* (ds == *null*) *throw* *new* ExecutorException("ResultLoader could
> not load lazily. DataSource was not configured.");
>
> Connection conn = ds.getConnection();
>
> conn = wrapConnection(conn);
>
> Transaction tx = txFactory.newTransaction(conn,
> *false*);
>
> *return* configuration.newExecutor(tx, ExecutorType.*SIMPLE*);
>
> }
>

RE: Potential connection problem when using managed transactions in iBATIS 3

Posted by Poitras Christian <Ch...@ircm.qc.ca>.
Thanks for the hint!

________________________________
From: Rick.Wellman [mailto:Rick.Wellman@kiewit.com]
Sent: Thursday, November 19, 2009 11:36 AM
To: user-java@ibatis.apache.org
Subject: RE: Potential connection problem when using managed transactions in iBATIS 3

Even if it is not an "issue", I think it is usually good form to include your solution to a problem when you post.  Not just "hey, *I* solved *my* problem, so good luck with yours".

From: Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca]
Sent: Thursday, November 19, 2009 7:38 AM
To: 'user-java@ibatis.apache.org'
Subject: RE: Potential connection problem when using managed transactions in iBATIS 3

Not yet.
I wasn't sure it was a real issue, so I didn't file a Jira, I'll do it in a few minutes.

Thanks Clinton!

Christian

________________________________
From: Clinton Begin [mailto:clinton.begin@gmail.com]
Sent: Wednesday, November 18, 2009 8:31 PM
To: user-java@ibatis.apache.org
Subject: Re: Potential connection problem when using managed transactions in iBATIS 3
Did you already file a Jira ticket for this one?
On Wed, Nov 18, 2009 at 1:43 PM, Poitras Christian <Ch...@ircm.qc.ca>> wrote:
As a workaround, it is easy to create a custom TransactionFactory and Transaction to make sure that the connection is closed properly and at the right time.
I've just managed to do so with Spring.

Christian

________________________________
From: Clinton Begin [mailto:clinton.begin@gmail.com<ma...@gmail.com>]
Sent: Tuesday, November 10, 2009 10:26 AM
To: user-java@ibatis.apache.org<ma...@ibatis.apache.org>
Subject: Re: Potential connection problem when using managed transactions in iBATIS 3
That is a little odd.  It looks like I intended for something else there.  I'll look at it.

Clinton
On Tue, Nov 10, 2009 at 8:09 AM, Poitras Christian <Ch...@ircm.qc.ca>> wrote:
What is the expected behaviour when calling dataSouce.getConnection() for managed transactions in iBATIS 3?

I find suspicious that ResultLoader calls dataSouce.getConnection() at line 89 which could create an unexpected connection. And since managed transaction is used, the connection may never be closed.


Christian


Here is the code from ResultLoader which calls dataSouce.getConnection() :
private Executor newExecutor() throws SQLException {

Environment environment =
configuration.getEnvironment();
if (environment == null)
throw new ExecutorException("ResultLoader could not load lazily. Environment was not configured.");

TransactionFactory txFactory = environment.getTransactionFactory();
if (txFactory == null)
throw new ExecutorException("ResultLoader could not load lazily. Transaction Factory was not configured.");

DataSource ds = environment.getDataSource();
if (ds == null) throw new ExecutorException("ResultLoader could not load lazily. DataSource was not configured.");

Connection conn = ds.getConnection();

conn = wrapConnection(conn);

Transaction tx = txFactory.newTransaction(conn,
false);
return configuration.newExecutor(tx, ExecutorType.SIMPLE);

}



Re: Potential connection problem when using managed transactions in iBATIS 3

Posted by Clinton Begin <cl...@gmail.com>.
Just to be fair, Christian did do that in a previous mail on this thread...
not sure if your comment was directed at him or not.  But Christian is one
of the more active community members, who regularly submits Jira tickets
with patches and tests...

Clinton

On Thu, Nov 19, 2009 at 9:36 AM, Rick.Wellman <Ri...@kiewit.com>wrote:

>  Even if it is not an “issue”, I think it is usually good form to include
> your solution to a problem when you post.  Not just “hey, **I** solved **
> my** problem, so good luck with yours”.
>
>
>
> *From:* Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca]
> *Sent:* Thursday, November 19, 2009 7:38 AM
>
> *To:* 'user-java@ibatis.apache.org'
> *Subject:* RE: Potential connection problem when using managed
> transactions in iBATIS 3
>
>
>
> Not yet­.
>
> I wasn't sure it was a real issue, so I didn't file a Jira, I'll do it in a
> few minutes.
>
>
>
> Thanks Clinton!
>
>
>
> Christian
>
>
>  ------------------------------
>
> *From:* Clinton Begin [mailto:clinton.begin@gmail.com]
> *Sent:* Wednesday, November 18, 2009 8:31 PM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: Potential connection problem when using managed
> transactions in iBATIS 3
>
> Did you already file a Jira ticket for this one?
>
> On Wed, Nov 18, 2009 at 1:43 PM, Poitras Christian <
> Christian.Poitras@ircm.qc.ca> wrote:
>
> As a workaround, it is easy to create a custom TransactionFactory and
> Transaction to make sure that the connection is closed properly and at the
> right time.
>
> I've just managed to do so with Spring.
>
>
>
> Christian
>
>
>  ------------------------------
>
> *From:* Clinton Begin [mailto:clinton.begin@gmail.com]
> *Sent:* Tuesday, November 10, 2009 10:26 AM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: Potential connection problem when using managed
> transactions in iBATIS 3
>
> That is a little odd.  It looks like I intended for something else there.
> I'll look at it.
>
> Clinton
>
> On Tue, Nov 10, 2009 at 8:09 AM, Poitras Christian <
> Christian.Poitras@ircm.qc.ca> wrote:
>
> What is the expected behaviour when calling dataSouce.getConnection() for
> managed transactions in iBATIS 3?
>
>
>
> I find suspicious that ResultLoader calls dataSouce.getConnection() at line
> 89 which could create an unexpected connection. And since managed
> transaction is used, the connection may never be closed.
>
>
>
>
>
> Christian
>
>
>
>
>
> Here is the code from ResultLoader which calls dataSouce.getConnection() :
>
> *private* Executor newExecutor() *throws* SQLException {
>
> Environment environment =
>
> configuration.getEnvironment();
>
> *if* (environment == *null*)
>
> *throw* *new* ExecutorException("ResultLoader could not load lazily.
> Environment was not configured.");
>
> TransactionFactory txFactory = environment.getTransactionFactory();
>
> *if* (txFactory == *null*)
>
> *throw* *new* ExecutorException("ResultLoader could not load lazily.
> Transaction Factory was not configured.");
>
> DataSource ds = environment.getDataSource();
>
> *if* (ds == *null*) *throw* *new* ExecutorException("ResultLoader could
> not load lazily. DataSource was not configured.");
>
> Connection conn = ds.getConnection();
>
> conn = wrapConnection(conn);
>
> Transaction tx = txFactory.newTransaction(conn,
>
> *false*);
>
> *return* configuration.newExecutor(tx, ExecutorType.*SIMPLE*);
>
> }
>
>
>
>
>

RE: Potential connection problem when using managed transactions in iBATIS 3

Posted by "Rick.Wellman" <Ri...@kiewit.com>.
Even if it is not an "issue", I think it is usually good form to include
your solution to a problem when you post.  Not just "hey, *I* solved
*my* problem, so good luck with yours".

 

From: Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca] 
Sent: Thursday, November 19, 2009 7:38 AM
To: 'user-java@ibatis.apache.org'
Subject: RE: Potential connection problem when using managed
transactions in iBATIS 3

 

Not yet-.

I wasn't sure it was a real issue, so I didn't file a Jira, I'll do it
in a few minutes.

 

Thanks Clinton!

 

Christian

 

________________________________

From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Wednesday, November 18, 2009 8:31 PM
To: user-java@ibatis.apache.org
Subject: Re: Potential connection problem when using managed
transactions in iBATIS 3

Did you already file a Jira ticket for this one?

On Wed, Nov 18, 2009 at 1:43 PM, Poitras Christian
<Ch...@ircm.qc.ca> wrote:

As a workaround, it is easy to create a custom TransactionFactory and
Transaction to make sure that the connection is closed properly and at
the right time.

I've just managed to do so with Spring.

 

Christian

 

________________________________

From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Tuesday, November 10, 2009 10:26 AM
To: user-java@ibatis.apache.org
Subject: Re: Potential connection problem when using managed
transactions in iBATIS 3

That is a little odd.  It looks like I intended for something else
there.  I'll look at it.

Clinton

On Tue, Nov 10, 2009 at 8:09 AM, Poitras Christian
<Ch...@ircm.qc.ca> wrote:

What is the expected behaviour when calling dataSouce.getConnection()
for managed transactions in iBATIS 3?

 

I find suspicious that ResultLoader calls dataSouce.getConnection() at
line 89 which could create an unexpected connection. And since managed
transaction is used, the connection may never be closed.

 

 

Christian

 

 

Here is the code from ResultLoader which calls dataSouce.getConnection()
:

private Executor newExecutor() throws SQLException { 

Environment environment = 

configuration.getEnvironment(); 

if (environment == null) 

throw new ExecutorException("ResultLoader could not load lazily.
Environment was not configured."); 

TransactionFactory txFactory = environment.getTransactionFactory();

if (txFactory == null) 

throw new ExecutorException("ResultLoader could not load lazily.
Transaction Factory was not configured."); 

DataSource ds = environment.getDataSource();

if (ds == null) throw new ExecutorException("ResultLoader could not load
lazily. DataSource was not configured."); 

Connection conn = ds.getConnection();

conn = wrapConnection(conn);

Transaction tx = txFactory.newTransaction(conn, 

false); 

return configuration.newExecutor(tx, ExecutorType.SIMPLE); 

}

 

 


RE: Potential connection problem when using managed transactions in iBATIS 3

Posted by Poitras Christian <Ch...@ircm.qc.ca>.
Not yet.
I wasn't sure it was a real issue, so I didn't file a Jira, I'll do it in a few minutes.

Thanks Clinton!

Christian

________________________________
From: Clinton Begin [mailto:clinton.begin@gmail.com]
Sent: Wednesday, November 18, 2009 8:31 PM
To: user-java@ibatis.apache.org
Subject: Re: Potential connection problem when using managed transactions in iBATIS 3

Did you already file a Jira ticket for this one?

On Wed, Nov 18, 2009 at 1:43 PM, Poitras Christian <Ch...@ircm.qc.ca>> wrote:
As a workaround, it is easy to create a custom TransactionFactory and Transaction to make sure that the connection is closed properly and at the right time.
I've just managed to do so with Spring.

Christian

________________________________
From: Clinton Begin [mailto:clinton.begin@gmail.com<ma...@gmail.com>]
Sent: Tuesday, November 10, 2009 10:26 AM
To: user-java@ibatis.apache.org<ma...@ibatis.apache.org>
Subject: Re: Potential connection problem when using managed transactions in iBATIS 3

That is a little odd.  It looks like I intended for something else there.  I'll look at it.

Clinton

On Tue, Nov 10, 2009 at 8:09 AM, Poitras Christian <Ch...@ircm.qc.ca>> wrote:
What is the expected behaviour when calling dataSouce.getConnection() for managed transactions in iBATIS 3?

I find suspicious that ResultLoader calls dataSouce.getConnection() at line 89 which could create an unexpected connection. And since managed transaction is used, the connection may never be closed.


Christian


Here is the code from ResultLoader which calls dataSouce.getConnection() :

private Executor newExecutor() throws SQLException {

Environment environment =

configuration.getEnvironment();

if (environment == null)

throw new ExecutorException("ResultLoader could not load lazily. Environment was not configured.");

TransactionFactory txFactory = environment.getTransactionFactory();

if (txFactory == null)

throw new ExecutorException("ResultLoader could not load lazily. Transaction Factory was not configured.");

DataSource ds = environment.getDataSource();

if (ds == null) throw new ExecutorException("ResultLoader could not load lazily. DataSource was not configured.");

Connection conn = ds.getConnection();

conn = wrapConnection(conn);

Transaction tx = txFactory.newTransaction(conn,

false);

return configuration.newExecutor(tx, ExecutorType.SIMPLE);

}



Re: Potential connection problem when using managed transactions in iBATIS 3

Posted by Clinton Begin <cl...@gmail.com>.
Did you already file a Jira ticket for this one?

On Wed, Nov 18, 2009 at 1:43 PM, Poitras Christian <
Christian.Poitras@ircm.qc.ca> wrote:

>  As a workaround, it is easy to create a custom TransactionFactory and
> Transaction to make sure that the connection is closed properly and at the
> right time.
> I've just managed to do so with Spring.
>
> Christian
>
>  ------------------------------
> *From:* Clinton Begin [mailto:clinton.begin@gmail.com]
> *Sent:* Tuesday, November 10, 2009 10:26 AM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: Potential connection problem when using managed
> transactions in iBATIS 3
>
> That is a little odd.  It looks like I intended for something else there.
> I'll look at it.
>
> Clinton
>
> On Tue, Nov 10, 2009 at 8:09 AM, Poitras Christian <
> Christian.Poitras@ircm.qc.ca> wrote:
>
>>  What is the expected behaviour when calling dataSouce.getConnection()
>> for managed transactions in iBATIS 3?
>>
>> I find suspicious that ResultLoader calls dataSouce.getConnection() at
>> line 89 which could create an unexpected connection. And since managed
>> transaction is used, the connection may never be closed.
>>
>>
>> Christian
>>
>>
>> Here is the code from ResultLoader which calls dataSouce.getConnection() :
>>
>> *private* Executor newExecutor() *throws* SQLException {
>>
>> Environment environment =
>> configuration.getEnvironment();
>>
>> *if* (environment == *null*)
>>
>> *throw* *new* ExecutorException("ResultLoader could not load lazily.
>> Environment was not configured.");
>>
>> TransactionFactory txFactory = environment.getTransactionFactory();
>>
>> *if* (txFactory == *null*)
>>
>> *throw* *new* ExecutorException("ResultLoader could not load lazily.
>> Transaction Factory was not configured.");
>>
>> DataSource ds = environment.getDataSource();
>>
>> *if* (ds == *null*) *throw* *new* ExecutorException("ResultLoader could
>> not load lazily. DataSource was not configured.");
>>
>> Connection conn = ds.getConnection();
>>
>> conn = wrapConnection(conn);
>>
>> Transaction tx = txFactory.newTransaction(conn,
>> *false*);
>>
>> *return* configuration.newExecutor(tx, ExecutorType.*SIMPLE*);
>>
>> }
>>
>
>

RE: Potential connection problem when using managed transactions in iBATIS 3

Posted by Poitras Christian <Ch...@ircm.qc.ca>.
As a workaround, it is easy to create a custom TransactionFactory and Transaction to make sure that the connection is closed properly and at the right time.
I've just managed to do so with Spring.

Christian

________________________________
From: Clinton Begin [mailto:clinton.begin@gmail.com]
Sent: Tuesday, November 10, 2009 10:26 AM
To: user-java@ibatis.apache.org
Subject: Re: Potential connection problem when using managed transactions in iBATIS 3

That is a little odd.  It looks like I intended for something else there.  I'll look at it.

Clinton

On Tue, Nov 10, 2009 at 8:09 AM, Poitras Christian <Ch...@ircm.qc.ca>> wrote:
What is the expected behaviour when calling dataSouce.getConnection() for managed transactions in iBATIS 3?

I find suspicious that ResultLoader calls dataSouce.getConnection() at line 89 which could create an unexpected connection. And since managed transaction is used, the connection may never be closed.


Christian


Here is the code from ResultLoader which calls dataSouce.getConnection() :

private Executor newExecutor() throws SQLException {

Environment environment =

configuration.getEnvironment();

if (environment == null)

throw new ExecutorException("ResultLoader could not load lazily. Environment was not configured.");

TransactionFactory txFactory = environment.getTransactionFactory();

if (txFactory == null)

throw new ExecutorException("ResultLoader could not load lazily. Transaction Factory was not configured.");

DataSource ds = environment.getDataSource();

if (ds == null) throw new ExecutorException("ResultLoader could not load lazily. DataSource was not configured.");

Connection conn = ds.getConnection();

conn = wrapConnection(conn);

Transaction tx = txFactory.newTransaction(conn,

false);

return configuration.newExecutor(tx, ExecutorType.SIMPLE);

}