I try using the parallelStream() in DAO with Spring @Transactional annotations and get so problem:
@Transactional
public void processCo
Well, I have a guess consists of several guesses:
session-per-thread;Object you wrote in example is in fact some entity that uses lazy loading;processOne() method uses entity properties that are loaded lazily;parallelStream() has no session available (probably in ThreadLocal, don't remember how technically sessions are bound to threads);That altogether causing the problem you have. The behavior looks quite strange to me, so I suggest to do the following:
parallelStream() again;parallelStream().Alternative way to go: detaching all list elements from session before doing parallelStream().
Although as Marko wrote in comments, Session is not thread-safe, so that means you have to get rid of Session usage either by removing lazy loading, or by detaching all entities from session.