Hi, I am having a problem using Spring's test framework with Hibernate sessions. Because of the way spring's transactions work, the tests will do things that actually DO NOT occur in the real, production environment.
For example
* Hibernate will not throw LazyInitializationExceptions when I'm testing controllers... but once in the real application, they are thrown. I want to know this before I deploy in tomcat so it just "works".
* If I forget to call a MyService.store() method, the changes are still persisted because the session is open when I run the test, whereas the session is not open in the real application
* Hibernate will not throw the error: "this object will be re-saved on cascade" in the tests... but it will in actual deployment.
Also, sometimes changes are not getting rolled back - particularly some oddball updates at various levels in the tests (controller, service or dao... and not all of them are behaving erratically - just some).
Are there any step-by-step tutorials to getting spring 2.5 and Hibernate tests working "as expected"? As in, I want my tests to behave EXACTLY like the real deployment. If not tutorials, suggestions on what is most likely happening? Besides this, everything is working 100% correct.
This problem is causing so much headache as I cannot predict if my application is going to work unless I actually test it in tomcat... and I want it to be more scientific than that. This is driving me nuts.
You can see some code samples here:
http://forum.springsource.org/showthread.php?t=72546Thank you.