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:
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.
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:
Michael J. McCurrey
Read with me at http://www.mccurrey.com
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
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:
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 :)
|Free forum by Nabble||Edit this page|