Apr 14th, 2009, 06:28 PM
Multithreading, Spring + Hibernate transactionally
I have a service class which currently runs in a single thread using spring + hibernate and within a transaction. If there are any failures the whole transaction is rolled back. In order to speed up the process I would like to multithread the processing but this has issues that I am not clear how to resolve the following situations :
- If multiple threads are kicked off I am assuming each works with a different hibernate session/database connection. How would you ensure that all changes in all threads are rolled back if any problems are encountered in any of the threads.
- If I delete objects in one thread I have to ensure that those changes are visible in the other threads otherwise there will a blocking lock issue to deal with if I try to manipulate the same data in other threads.
Any tips/suggestions would be much appreciated and if there is an example app that demonstates this type of functionality that would be great.
Tags for this Thread