darryl_staflund
02-01-2007, 06:49 PM
Hi all,
Does anyone have any tips on how I might be able to integrate Spring's ADO transaction manage features with IBatis.NET? I have managed to integrate Spring.NET and IBatis.NET after a little work and would like to have Spring manage transactions.
Here is how I do my Spring.NET / IBatis.NET integration. I won't detail everything but will cut and paste some of the more important code:
<!-- ################################################## ##################
##
## Section: Ibatis Manager Builder.
## Notes: This class is responsible for parsing the various
## IBatis.NET configuration files. It is the start of
## everything IBatis in our project.
##
################################################## ################## -->
<object id="DAOManagerBuilder"
type="IBatisNet.DataAccess.Configuration.DomDaoManagerBu ilder, IBatisNet.DataAccess"
init-method="Configure">
<description>
<![CDATA[
This object is responsible for parsing the iBatis.NET configuration files and then
creating 'IBatisNET.DataMapper.IDaoManager' singletons for each DAO context defined
in 'dao.config'.
The 'Configure' initialization kicks off the parsing process. Although it is possible
to pass the URI of 'dao.config' to the 'Configure' method outside of Spring.NET, I have
not found a way to pass parameters to initialization methods from within a Spring.NET
configuration file. As such, the 'dao.config' file must be located in the root of the
web application (i.e. the default iBatis.NET location for the file.)
]]>
</description>
</object>
<!-- ################################################## ##################
##
## IBatis Context: CED Mirror
##
################################################## ################## -->
<object id="CEDMirrorContextDAOManager"
depends-on="DAOManagerBuilder"
type="IBatisNet.DataAccess.DaoManager"
factory-method="GetInstance">
<description>
<![CDATA[
This DAO Manager is responsible for managing iBatis.NET data access objects (DAOs)
that reside within the CED Mirror Context specified within the 'dao.config' file.
Since this manager object is created by the 'DAOManagerBuilder' object, the
'DAOManagerBuilder' object must be initialized by Spring.NET before this object.
As such, this dependency is noted in the 'depends-on' attribute.
Since this object is a singleton, the static 'GetInstance' factory method is used
to obtain an instance of it. The name of the iBatis.NET context defined in the
'dao.config' file is passed to the factory method as an argument.
]]>
</description>
<constructor-arg type="string" value="CEDMirrorContext" />
</object>
<object id="CEDMirrorContextDAO" abstract="true">
<description>
<![CDATA[
This is an abstract object that all concrete DAO objects within this iBatis.NET context
are to extend. It defines properties common to all DAOs within the context.
]]>
</description>
<property name="DAOManager" ref="CEDMirrorContextDAOManager" />
</object>
<object id="BusinessUnitDAO" type="NSII.src.daos.impl.BusinessUnitDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="CompanyDAO" type="NSII.src.daos.impl.CompanyDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="EmployeeDAO" type="NSII.src.daos.impl.EmployeeDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="JobTypeDAO" type="NSII.src.daos.impl.JobTypeDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="OrganizationUnitDAO" type="NSII.src.daos.impl.OrganizationUnitDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
Basically with this configuration, I can inject IBatis DAOs directly into my service classes. However, I still have to use the IBatis IDaoManager to manage transactions.
What I would like to know if there is something I can do in the config files to integrate IBatis's IDaoManager transaction features with those of Spring.
Thanks,
Darryl
Does anyone have any tips on how I might be able to integrate Spring's ADO transaction manage features with IBatis.NET? I have managed to integrate Spring.NET and IBatis.NET after a little work and would like to have Spring manage transactions.
Here is how I do my Spring.NET / IBatis.NET integration. I won't detail everything but will cut and paste some of the more important code:
<!-- ################################################## ##################
##
## Section: Ibatis Manager Builder.
## Notes: This class is responsible for parsing the various
## IBatis.NET configuration files. It is the start of
## everything IBatis in our project.
##
################################################## ################## -->
<object id="DAOManagerBuilder"
type="IBatisNet.DataAccess.Configuration.DomDaoManagerBu ilder, IBatisNet.DataAccess"
init-method="Configure">
<description>
<![CDATA[
This object is responsible for parsing the iBatis.NET configuration files and then
creating 'IBatisNET.DataMapper.IDaoManager' singletons for each DAO context defined
in 'dao.config'.
The 'Configure' initialization kicks off the parsing process. Although it is possible
to pass the URI of 'dao.config' to the 'Configure' method outside of Spring.NET, I have
not found a way to pass parameters to initialization methods from within a Spring.NET
configuration file. As such, the 'dao.config' file must be located in the root of the
web application (i.e. the default iBatis.NET location for the file.)
]]>
</description>
</object>
<!-- ################################################## ##################
##
## IBatis Context: CED Mirror
##
################################################## ################## -->
<object id="CEDMirrorContextDAOManager"
depends-on="DAOManagerBuilder"
type="IBatisNet.DataAccess.DaoManager"
factory-method="GetInstance">
<description>
<![CDATA[
This DAO Manager is responsible for managing iBatis.NET data access objects (DAOs)
that reside within the CED Mirror Context specified within the 'dao.config' file.
Since this manager object is created by the 'DAOManagerBuilder' object, the
'DAOManagerBuilder' object must be initialized by Spring.NET before this object.
As such, this dependency is noted in the 'depends-on' attribute.
Since this object is a singleton, the static 'GetInstance' factory method is used
to obtain an instance of it. The name of the iBatis.NET context defined in the
'dao.config' file is passed to the factory method as an argument.
]]>
</description>
<constructor-arg type="string" value="CEDMirrorContext" />
</object>
<object id="CEDMirrorContextDAO" abstract="true">
<description>
<![CDATA[
This is an abstract object that all concrete DAO objects within this iBatis.NET context
are to extend. It defines properties common to all DAOs within the context.
]]>
</description>
<property name="DAOManager" ref="CEDMirrorContextDAOManager" />
</object>
<object id="BusinessUnitDAO" type="NSII.src.daos.impl.BusinessUnitDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="CompanyDAO" type="NSII.src.daos.impl.CompanyDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="EmployeeDAO" type="NSII.src.daos.impl.EmployeeDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="JobTypeDAO" type="NSII.src.daos.impl.JobTypeDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
<object id="OrganizationUnitDAO" type="NSII.src.daos.impl.OrganizationUnitDAOSqlMapImpl, NSII" parent="CEDMirrorContextDAO" />
Basically with this configuration, I can inject IBatis DAOs directly into my service classes. However, I still have to use the IBatis IDaoManager to manage transactions.
What I would like to know if there is something I can do in the config files to integrate IBatis's IDaoManager transaction features with those of Spring.
Thanks,
Darryl