开发者

Why my SqlConnection hang forever when working with NHibernte + Spring.Net

I wrote an test case extending the Spring.Net's AbstractTransactionalDbProviderSpringContextTests class and trying to do something like this.

Step.1 MyHibernateDao.Find(id)
Step.2 Use SqlConnection API to inser开发者_如何学JAVAt some record into database.

Either step.1 or step.2 can run successfully, but if I put them together, step.2 will hang forever(until the timeout.)

If I add the following statements:

Step.1 MyHibernateDao.Find(id) //My Find method does not have [Transaction] annotation.
SessionFactory.GetCurrentSession().Flush()
SessionFactory.GetCurrentSession().Close()
Step.2 Use SqlConnection API to insert some record into database.

both step.1 and step.2 can run successfully, of course the tear down will fail, since session is closed already.

I am wondering why the test hang at step.2? there is no reason that one connection need to wait another connection to return, or need to wait a table lock or what, it is simply read.

I am confused here, any idea?

Thanks in advance.


Are you using Spring.NET's transaction management or NHibernate's? You may need to check your session factory configuration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜