We use our own session handler, at least, which we did to inject some extra
information using SET CONTEXT_INFO at the start of a transaction.

The short version: Make your config file point to a custom session handler.
Make a custom session handler to return your custom session.

The long version:

First, in our DaoConfig.xml file, we tell iBATIS that we want to use our own
session handler in Foo.Bar.DLL:
 
<!-- Let's use our own DAO session handler for database auditing purposes
-->
<daoSessionHandlers>
        <handler id="UndiesDaoSessionHandler"
implementation="Foo.Bar.SkiviezSqlMapDaoSessionHandler, Foo.Bar" />
</daoSessionHandlers>

SkiviezSqlMapDaoSessionHandler.cs implements the IDaoSessionHandler
interface, returning our SkiviezSqlMapDaoSession class. For the Configure()
method, I just copied the code from the same method in
SqlMapDaoSessionHandler.cs in the iBATIS source. (Why aren't these methods
virtual?!)

SkiviezSqlMapDaoSession.cs inherits from SqlMapDaoSession. By overriding the
methods here (like BeginTransaction(), etc.), we can control all aspects of
the transactions that iBATIS uses with the data source.

Hope this helps.

V/R,
Nicholas Piasecki

Software Developer
Skiviez, Inc.
[EMAIL PROTECTED]
804-550-9406

From: Gulsharan Goraya [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 26, 2008 12:25 PM
To: '[email protected]'
Subject: External transaction management

Hi All

I am trying to integrate IBatis.Net with one of our legacy applications.
Now, the problem is that I need to do it one domain object at a time. So,
for that I need to integrate our current transaction management system with
IBatis. 

I tried using a custom DaoSessionHandler. However, it's still using the
datasource as defined in Dao.config. Could someone highlight as to what all
IBatis classes/interfaces I need override/implement in order to make IBatis
use my custom transaction, session, command, datasource etc. 

Really looking forward to you guys for some help.

Thanks,
Gul


Reply via email to