Hello everybody,

 

            I spent long hours to try configuring IBatis to support Informix and SQL Server transactions in the same application using

IBatis Datamapper and DataAccess.

 

            I registered the bug I told before on JIRA and the Infomix provider configuration. One day somebody will need it, I hope J

 

Now I’d like to solve a limitation on DataAccess 1.6.1. Before I suggest a new improvement I’d like to ask my friends J

 

SqlMapDaoSessionHandler will keep just one instance for SqlMapper. I could see that in big picture on documentation and in the SqlMapDaoSessionHandler code.

 

This class just keeps: private SqlMapper _sqlMap = null;

So, when using two contexts, the method Configure will set the value for this attribute (sqlMap) two times. The final value will

be the value of the second datamapper config on the second context.

 

In my case, I need to use more than one SqlMappers (see: http://www.agcsolucoes.com/dao.config.txt )

 

So I wrote on SqlMapDaoSessionHandler.cs:

 

HybridDictionary _sqlMapDictionary = new HybridDictionary();

private SqlMapper _sqlMap = null;

 

The complete code is on http://www.agcsolucoes.com/SqlMapDaoSessionHandler.cs.txt

 

I tested, trying to persist the same object in two databases:

 

DaoManager DaoManagerSQL = DAOManagerConfigHelper.getInstance().getDaoManager(DAOManagerConfigHelper.SGBD.SQLServer);

DaoManager DaoManagerIfx = DAOManagerConfigHelper.getInstance().getDaoManager(DAOManagerConfigHelper.SGBD.Informix);

 

novoMembro.NomeMembro = "Anderson";

novoMembro.MostraEmail = true;

novoMembro.HomePage = "www.agcsolucoes.com";

novoMembro.Assinatura = "@nders0n";

 

MembroDao = DaoManagerSQL[typeof(IMembroDao)] as IMembroDao;

DaoManagerSQL.OpenConnection();

MembroDao.InsertMembro(novoMembro);

DaoManagerSQL.CloseConnection();

 

MembroDao2 = DaoManagerIfx[typeof(IMembroDao)] as IMembroDao;

DaoManagerIfx.OpenConnection();

MembroDao2.InsertMembro(novoMembro);

DaoManagerIfx.CloseConnection();

 

AMAZING! It worked fine! … The next test will be using distributed transactions.

 

I think it’s very important to be a part of IBatis DataAccess. What About ?

 

Regards,

Anderson

Reply via email to