title: java stream api and transactional batch processing
body: <p>I would realy like to save entities in a batch using one transaction, like this:</p>
  
  <pre><code>    @Transactional
  public &lt;T extends EntityInterface&gt; Stream&lt;T&gt; batchSave(Stream&lt;T&gt; entities, Integer flushCount) {
      EntityManager em = getEntityManager();
      return entities.map((t) -&gt; {
          if (t.isTransient()) {
              em.persist(t);
              return t;
          } else {
              return em.merge(t);
          }
      });
  }
  </code></pre>
  
  <p>But unfortunately stream processing looses the transaction. Is there any way to make this work?</p>
  
  <p>Bye</p>