Question

I am working on a project which makes extensive use of spring transactions. I t so happened that i was throwing an exception AND NOT HANDLING IT PROPERLY which does not commit or rollback the transact Ion. So the connection remains active even when the thread is stopped. When new request to the web server ( Apache tomcat 7.0) comes the spring provides the earlier connection to the new thread. Since the thread didn't started the connection so the thread couldn't close it either ie .commit doesn't work. because of which the objects are not getting persisted in database in the consequent transactions even when there is no exception. How can i work around the problem so that i can detect where is the actual problem happening or can a design an exit point where i can explicitly close the transaction before response is sent to browser.

No correct solution

OTHER TIPS

A runtime unchecked exception or error that is thrown from a @Transactional method will rollback that transaction by default; a return or a checked exception will commit the transaction by default. You can tell Spring to override that behaviour using the annotation type elements of the @Transactional annotation.

The Spring Framework reference manual has an entire chapter devoted to transaction management. You need to read and understand that as your starting point.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top