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 "Rafiq, Adnan" <ar...@carreker.com> on 2005/08/24 17:43:57 UTC

Multi-threading and Connections

I am in the process of re-writing some batch processes (that run outside of an app server) and would like to use iBatis as the persistence framework.

My requirements are as follows:

1. the process will spawn multiple threads and each thread needs its own connection. how is this handled in ibatis? does each thread automatically get its own connection or do I need to write more code?

2. the process commits/rollbacks at the very end by default however, some batch processes may do commits in the middle of processing (e.g. in a for-loop) I believe I can just issue commits using the iBatis API. is this correct?

3. I plan to use a Simple JDBC datasource as TX manager. Is this the best approach or are there better alternatives out there?

Any help in this matter is greatly appreciated.



-----Original Message-----
From: Graeme J Sweeney [mailto:ibatis.user@gjsweeney.com]
Sent: Wednesday, August 24, 2005 10:23 AM
To: iBatis List
Subject: [REPOST] sqlMap + multiple deletes: getting the total number of
rows deleted


[Looks like my first post got lost when the list went down :-/]

Hi,

I'm a newbie to iBatis and as part of some unit-testing I need to confirm 
that the correct number of rows are deleted when removing some records.

If do

<delete id="deleteXY">
delete from X where id=#value#;
delete from Y where id=#value#;
</delete>

I get the number of rows deleted from Y only.

If I split the delete into two separate entries:

<delete id="deleteX">
delete from X where id=#value#;
</delete>

<delete id="deleteY">
delete from Y where id=#value#;
</delete>

and call them both, I get the expected number of rows deleted when I add them.

Is there a way to have only one call to <delete/> and get the total 
number of rows deleted ?

TIA.

-- 
Graeme -

Re: Multi-threading and Connections

Posted by Larry Meadors <la...@gmail.com>.
On 8/24/05, Rafiq, Adnan <ar...@carreker.com> wrote:
> 1. the process will spawn multiple threads and each thread needs its 
> own connection. how is this handled in ibatis? does each thread 
> automatically get its own connection or do I need to write more code?

That is the default behavior, yes.

> 2. the process commits/rollbacks at the very end by default however, 
> some batch processes may do commits in the middle of processing 
> (e.g. in a for-loop) I believe I can just issue commits using the iBatis 
> API. is this correct?

Not sure what you mean here..you can commit using the sqlmap api.

> 3. I plan to use a Simple JDBC datasource as TX manager. Is this the 
> best approach or are there better alternatives out there?

Should work ok.

> 
> 
> -----Original Message-----
> From: Graeme J Sweeney [mailto:ibatis.user@gjsweeney.com]
> Sent: Wednesday, August 24, 2005 10:23 AM

PLEASE do not hijack other threads like this..

Larry