Hello,

I'm new to iBatis .NET and had a quick question about how the session/transaction stuff should work. The documentation examples shows something like this:

try
{
   sqlMap.BeginTransaction();
   Item item = (Item) sqlMap.QueryForObject("getItem", itemId);
   item.Description = newDescription;
   sqlMap.Update("updateItem", item);
   sqlMap.CommitTransaction();
}
catch {
   sqlMap.RollBackTransaction();
}

Which works fine in this simple case where all of the transaction logic exists in the data layer. In my case, I have several different Data Access Objects I've created (roughly one for each of my entity objects), and from my business logic layer I want to call several methods across the different DAOs and have them all participate in a transaction. Can someone guide me in the right direction?

All the DAO classes extend from a common base DAO which can easily begin/rollback/commit a transaction by getting an instance of the ISqlMapper and calling the appropriate methods. However since the mapper is a singleton, and a transaction has been started, wouldn't this then cause other DAO methods which may be called to inadvertently participate in the transaction since each DAO would be using the same ISqlMapper instance?

Thanks,
Mike


Reply via email to