title: Using EntityManager unwrap method in a bean managed transaction
body: <p>I am using the Hibernate Session obtained from <code>em.unwrap(..)</code> method. I couldn't seem to find any info on whether I have to release it after usage. The transaction is managed by the bean and the entity manager is injected using <code>@Inject</code>.</p>
  
  <pre><code>    boolean transactionSuccess = false;
      try {
          utx.begin();
          final Session session = em.unwrap(Session.class);
          transactionSuccess = true;
      } finally {
          commitOrRollback(transactionSuccess);
      }
  </code></pre>
  
  <p>I presume that the entity manager instance is managed by the container. Since the Session is more or less the underlying implementation do I have to release it? It is <code>AutoCloseable</code> after all.</p>
  
  <p>the only relevant info i found was this (but it seems vanilla JPA):
  <a href="https://stackoverflow.com/questions/14402330/after-using-the-unwrap-method-on-entitymanager-to-get-the-native-hibernate-sessi">After using the unwrap method on entitymanager to get the native hibernate session do I have to close both?</a></p>