Jef*_*nal 6 nhibernate flush transactionscope distributed-transactions nhibernate-3
在NHibernate 3.0中,FlushMode.Auto仅在环境事务下运行时无效(即,无需启动NHibernate事务).应该是?
using (TransactionScope scope = new TransactionScope())
{
ISession session = sessionFactory.OpenSession();
MappedEntity entity = new MappedEntity() { Name = "Entity", Value = 20 };
session.Save(entity);
entity.Value = 30;
session.SaveOrUpdate(entity);
// This returns one entity, when it should return none
var list = session.
CreateQuery("from MappedEntity where Value = 20").
List<MappedEntity>();
}
Run Code Online (Sandbox Code Playgroud)
(从这个相关问题无耻地偷走的例子)
在NHibernate的来源,我可以看到这就是它检查是否有正在进行中(在一个事务SessionImpl.AutoFlushIfRequired),但相关方法(SessionImpl.TransactionInProgress)不考虑环境事务-不像它的近亲ConnectionManager.IsInActiveTransaction,这确实考虑环境事务.
好消息.感谢Jeff Sternal(他很好地确定了问题)我更新了https://nhibernate.jira.com/browse/NH-3583并感谢NH工作人员,在即将发布的4.1版本中已经有了修复和拉取请求. xx此问题将得到修复.
| 归档时间: |
|
| 查看次数: |
4826 次 |
| 最近记录: |