views:

9

answers:

0

Hi everyone:

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 insert 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.