Issue
Java web
Spring MVC framework
In my service level, I wrote a @Transactional
method. In that method, I update some data in database and then read the data from the database later.
What surprises me is that when several requests come, inside the same thread, the data change is visible(which is supposed to be), but the data change is not visible in other thread.
Isn't different threads of one method build as one transaction?
And what should I do if I still want to use transaction and I want the same method called in different threads be in one transaction (the change of the data can be seen by each other)?
Solution
you may want to play with isolation
parameter of@Transactional
annotation. Spring by default uses.. hm.. DEFAULT
which is set by database, so may be different. You can try to use: READ_UNCOMMITTED
. More info: http://www.byteslounge.com/tutorials/spring-transaction-isolation-tutorial
Answered By - hi_my_name_is