We have a web application based on NSpring 1.2 and NHibernate 2 and use HibernateTemplate. The web application is configured to use OpenSessionInViewModule.
In our integration tests however the hibernate session is marked as InitDeferredClose and for the most part this works fine for our tests. There are some service functions that work fine in the context of the web application but fail when called from a test harness.
For example : I have one function that creates and updates a number of objects within a transaction. The function is marked with the Transaction attribute but the test fails with the message :
Illegal attempt to associate a collection with two open sessions
When called from the web application the transaction completes successfully
How should I be configuring spring and hibernate so that my Integration Tests replicate properly the functionnality of the Web application ?