yuanhuawei / mybatisnet

Automatically exported from code.google.com/p/mybatisnet
0 stars 0 forks source link

CommandTimeout on a statement basis #29

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What version of the MyBatis.NET are you using?
IBatisNet.DataMapper.dll (version 1.6.2)
IBatisNet.DataAccess.dll (version 1.9.2)

Issue:

Hello we've got very big problem with timeout expiring often when using Ibatis 
with long transactions.

I realized that SqlMapper methods (QueryForObject<T>, etc) ultimately rely on 
SqlMapSession.CreateCommand
and that method is the one setting the commandTimeout on the command.

My methods use code like this:

protected T Select(string statementName, object parameterObject)
{
    IDaoManager daoManager = DaoManager.GetInstance(this);
    SqlMapDaoSession sqlMapDaoSession = (SqlMapDaoSession)daoManager.LocalDaoSession;
    ISqlMapper mapper = sqlMapDaoSession.SqlMap;
    return mapper.QueryForObject<T>(statementName, parameterObject);
}

How can I change them to be able to set the CommandTimeout.
I saw that almost all the methods are public so I guess it should be possible.

Could you give me any advice or code snippet?
I know that the connection timeout is copied to the command timeout but
changing the connection timeout in the connection string is not viable for us
because we cannot increase the timeout in the whole application.

Thank you very much for your help

Original issue reported on code.google.com by m.tont...@gmail.com on 8 Apr 2011 at 10:33

GoogleCodeExporter commented 8 years ago
Check this fix:
http://code.google.com/p/mybatisnet/source/detail?r=15

Please check my issue(comment) to this fix too:
http://code.google.com/p/mybatisnet/issues/detail?id=10

Maybe it help you.

Original comment by dmu...@gmail.com on 11 Apr 2011 at 3:54