Transaction across multiple SqlMapConfig

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

Transaction across multiple SqlMapConfig

jozeibatis
Hello,

first of all I want to apologize for my bad english, I'll try to do my best.

I have a problem and I can't work out the solution. My application is divided in modules and for designing propuses every module has it's own SqlMapConfig and Mapper.

The application is composed by Core + Modules. Every module is in a .DLL

Everything works fine except when it comes to transactions. Even if all the SqlMapConfig shares the same conection string transactions are not working properly. Every Mapper(ISqlMapper) created is seen as a separate conection. I have one mapper for each SqlMapConfig.xml.  The escanario is the following:


OpenTransaction Core
(Core Mapper)
Insert into core object A
Insert into core object B

(Module Mapper)
Insert into Module 1 object C
Insert into Module 2 object e

commit Core transaction

When I get to the line code: Insert into Module 1 object C I get a connection timeout. That is because my transaction level is Serializable and the database is expecting that the Transaction Core finishes before doing something else. Ibatis is not seein both Mapper as the same connection.

Any ideas how I do that?

As a global idea I need transactions over DAO loaded by diferents SqlMaps pointing to the same db.

hope I make everythying clear.

I would appreciate a lot any advice you can give me.

regards, jose




Reply | Threaded
Open this post in threaded view
|

Re: Transaction across multiple SqlMapConfig

Michael McCurrey-3
What I currently do Jose is use the Castle framework and use its Transaction package.  I currently span transactions across Oracle, SQL Server, and Teradata.

You can find it here:  http://www.castleproject.org/



On Tue, Mar 23, 2010 at 5:51 AM, jozeibatis <[hidden email]> wrote:

Hello,

first of all I want to apologize for my bad english, I'll try to do my best.

I have a problem and I can't work out the solution. My application is
divided in modules and for designing propuses every module has it's own
SqlMapConfig and Mapper.

The application is composed by Core + Modules. Every module is in a .DLL

Everything works fine except when it comes to transactions. Even if all the
SqlMapConfig shares the same conection string transactions are not working
properly. Every DAO created is seen as a separate conection. The escanario
is the following:


OpenTransaction Core

Insert into core object A
Insert into core object B

Insert into Module 1 object C
Insert into Module 2 object e

commit Core transaction

When I get to the line code: Insert into Module 1 object C I get a
connection timeout. That is because my transaction level is Serializable and
the database is expecting that the Transaction Core finishes before doing
something else. Ibatis is not seein both Mapper as the same connection.

Any ideas how I do that?

As a global idea I need transactions over DAO loaded by diferents SqlMaps
pointing to the same db.

hope I make everythying clear.

I would appreciate a lot any advice you can give me.

regards, jose





--
View this message in context: http://old.nabble.com/Transaction-across-multiple-SqlMapConfig-tp28000351p28000351.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


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




--
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Transaction across multiple SqlMapConfig

jozeibatis
Hi! Thanks for the advice! I've been looking to Castle and Ibatis has also Transaction Scope hasn't it? What my gol is that both Mapper share the datasource, so they're seen as one by the db. I'm not happy using transaction global because it would be slower than both DAO seen as the same :S I hope u understand me, I have trouble beeing precie in English

Michael McCurrey-3 wrote
What I currently do Jose is use the Castle framework and use its Transaction
package.  I currently span transactions across Oracle, SQL Server, and
Teradata.

You can find it here:  http://www.castleproject.org/



On Tue, Mar 23, 2010 at 5:51 AM, jozeibatis
<jose.granja.martinez@gmail.com>wrote:

>
> Hello,
>
> first of all I want to apologize for my bad english, I'll try to do my
> best.
>
> I have a problem and I can't work out the solution. My application is
> divided in modules and for designing propuses every module has it's own
> SqlMapConfig and Mapper.
>
> The application is composed by Core + Modules. Every module is in a .DLL
>
> Everything works fine except when it comes to transactions. Even if all the
> SqlMapConfig shares the same conection string transactions are not working
> properly. Every DAO created is seen as a separate conection. The escanario
> is the following:
>
>
> OpenTransaction Core
>
> Insert into core object A
> Insert into core object B
>
> Insert into Module 1 object C
> Insert into Module 2 object e
>
> commit Core transaction
>
> When I get to the line code: Insert into Module 1 object C I get a
> connection timeout. That is because my transaction level is Serializable
> and
> the database is expecting that the Transaction Core finishes before doing
> something else. Ibatis is not seein both Mapper as the same connection.
>
> Any ideas how I do that?
>
> As a global idea I need transactions over DAO loaded by diferents SqlMaps
> pointing to the same db.
>
> hope I make everythying clear.
>
> I would appreciate a lot any advice you can give me.
>
> regards, jose
>
>
>
>
>
> --
> View this message in context:
> http://old.nabble.com/Transaction-across-multiple-SqlMapConfig-tp28000351p28000351.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-cs-help@ibatis.apache.org
>
>


--
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Transaction across multiple SqlMapConfig

Dave Curylo
Not knowing what your environment is, this may or may not be useful to you.  Using .NET 3.5 and SQL Server 2008, when you execute multiple statements using the same connection pool (same string) and within the same TransactionScope, the transaction will remain lightweight.  It is only promoted to a distributed transaction if you use a different connection string.  This was a big difference from .NET 2.0 and older versions of SQL Server and has allowed me to use a TransactionScope more effectively.

using(TransactionScope scope = new TransactionScope())
{
   // Multiple DataMapper calls can occur here using different mapping files
   // as long as they use the same connection string.
}

Read details about it in the section titled "Promotable Transactions in SQL Server 2008" here: http://msdn.microsoft.com/en-us/library/ms172070.aspx

Again, if you're not able to use .NET 3.5 or SQL Server 2008, I'm afraid this won't be helpful, but I just wanted to make you aware of it in case that is an option for you.

On Tue, Mar 23, 2010 at 9:47 AM, jozeibatis <[hidden email]> wrote:

Hi! Thanks for the advice! I've been looking to Castle and Ibatis has also
Transaction Scope hasn't it? What my gol is that both Mapper share the
datasource, so they're seen as one by the db. I'm not happy using
transaction global because it would be slower than both DAO seen as the same
:S I hope u understand me, I have trouble beeing precie in English


Michael McCurrey-3 wrote:
>
> What I currently do Jose is use the Castle framework and use its
> Transaction
> package.  I currently span transactions across Oracle, SQL Server, and
> Teradata.
>
> You can find it here:  http://www.castleproject.org/
>
>
>
> On Tue, Mar 23, 2010 at 5:51 AM, jozeibatis
> <[hidden email]>wrote:
>
>>
>> Hello,
>>
>> first of all I want to apologize for my bad english, I'll try to do my
>> best.
>>
>> I have a problem and I can't work out the solution. My application is
>> divided in modules and for designing propuses every module has it's own
>> SqlMapConfig and Mapper.
>>
>> The application is composed by Core + Modules. Every module is in a .DLL
>>
>> Everything works fine except when it comes to transactions. Even if all
>> the
>> SqlMapConfig shares the same conection string transactions are not
>> working
>> properly. Every DAO created is seen as a separate conection. The
>> escanario
>> is the following:
>>
>>
>> OpenTransaction Core
>>
>> Insert into core object A
>> Insert into core object B
>>
>> Insert into Module 1 object C
>> Insert into Module 2 object e
>>
>> commit Core transaction
>>
>> When I get to the line code: Insert into Module 1 object C I get a
>> connection timeout. That is because my transaction level is Serializable
>> and
>> the database is expecting that the Transaction Core finishes before doing
>> something else. Ibatis is not seein both Mapper as the same connection.
>>
>> Any ideas how I do that?
>>
>> As a global idea I need transactions over DAO loaded by diferents SqlMaps
>> pointing to the same db.
>>
>> hope I make everythying clear.
>>
>> I would appreciate a lot any advice you can give me.
>>
>> regards, jose
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Transaction-across-multiple-SqlMapConfig-tp28000351p28000351.html
>> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> --
> Michael J. McCurrey
> Read with me at http://www.mccurrey.com
> http://chaoticmindramblings.blogspot.com/
>
>

--
View this message in context: http://old.nabble.com/Transaction-across-multiple-SqlMapConfig-tp28000351p28001144.html
Sent from the iBATIS - User - Cs 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: Transaction across multiple SqlMapConfig

jozeibatis
Thank for the reply! I was using

using (TransactionScope tx = new TransactionScope())

but somehow the data is not commited once inserted! Everything seems to work fine but after I realise that nothing has been inserted on the database! I think it's no commiting anything and the data gets lost! Any ideas? I really apreciat your help :)
Reply | Threaded
Open this post in threaded view
|

Re: Transaction across multiple SqlMapConfig

jozeibatis
ok! I wasn't commiting anything! using tx.Complete(); solved the problem :))