The Spring docs specify the RowCallbackHandler argument as an “object that will extract results, one row at a time”. I see that processRow() is called once per row, but can these calls be concurrent?
I am having my RowCallbackHandler maintain state, including building a Collection of processed objects and occasionally submitting that Collection for further processing. I need to know if this Collection might be modified concurrently, or if I can trust that only one processRow() is happening at a time.
It is really up to you. If you’ve seen the source code,
RowCallbackHandleryou provide is wrapped inRowCallbackHandlerResultSetExtractoradapter class and then wrapped again inQueryStatementCallback(sic!).Never mind, the point is: if you pass the same
RowCallbackHandlerinstance to two concurrentquery()executions, Spring will use the same object through all this layers. But if you create new instance ofRowCallbackHandlerper everyquery()execution, you are safe.