title: Java .parallelStream() with spring annotated methods
body: <p>I try using the <code>parallelStream()</code> in DAO with Spring <code>@Transactional</code> annotations and get so problem:</p>
  
  <pre><code>@Transactional
  public void processCollection(Collection&lt;Object&gt; objects) {
      objects.parallelStream()
              .forEach(this::processOne);  //throw exception
  }
  
  @Transactional
  public void processOne(Object o) {
      ...
  }
  </code></pre>
  
  <p>Works correct:</p>
  
  <pre><code>@Transactional
  public void processCollection(Collection&lt;Object&gt; objects) {
      objects.stream()
              .forEach(this::processOne);  //work correctly
  }
  
  @Transactional
  public void processOne(Object o) {
      ...
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>org.hibernate.HibernateException: No Session found for current thread
  org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106)
  org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:978)
  </code></pre>
  
  <p>How can I use <code>@Transactional</code> annotated methods by <code>parallelStream()</code>?</p>
  
  <p><strong>Update</strong>
  Why this happen <a href="https://stackoverflow.com/questions/16835974/spring-transaction-manager-and-multithreading">Spring transaction manager and multithreading</a>
  But I hope spring 4 with java 8 support can provide some solution for this. Any ideas?</p>