title: IllegalStateException LogicalConnectionManagedImpl is closed Hibernate
body: <p>I'm using H2 Database with hibernate on JAVA and I'm getting a weird error.
  I have created my abstract repository to manage the basic CRUD operation.</p>
  <p>The exception I am getting is this:</p>
  <pre><code>java.lang.IllegalStateException: org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl@d20d74a is closed
  at org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.errorIfClosed(AbstractLogicalConnectionImplementor.java:37)
  at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:135)
  at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getConnectionForTransactionManagement(LogicalConnectionManagedImpl.java:254)
  at org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.rollback(AbstractLogicalConnectionImplementor.java:116)
  at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.rollback(JdbcResourceLocalTransactionCoordinatorImpl.java:294)
  at org.hibernate.engine.transaction.internal.TransactionImpl.rollback(TransactionImpl.java:139)
  at repositories.AbstractRepository.save(AbstractRepository.java:32)
  at services.ResultService.saveResult(ResultService.java:76)
  at services.API.WebRequestService.run(WebRequestService.java:124)
  at services.API.ThreadService.run(ThreadService.java:67)
  </code></pre>
  <p>AbstractRepository save method:</p>
  <pre><code>public &lt;T&gt; T save(T t) {
      Transaction transaction = null;
      try (Session session = HibernateConfig.getSessionFactory().openSession()) {
          transaction = session.beginTransaction();
          Serializable entityId = session.save(t);
          transaction.commit();
  
          T createdEntity = (T) session.get(t.getClass(), entityId);
          return createdEntity;
  
      } catch (Exception e) {
          if (transaction != null) {
              transaction.rollback();
          }
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  <p>I am a CS student and I am not very much familiar with Hibernate. I'm not getting this error on my computer, only on other computers with the JAR file builded.</p>
  <p>P.S English isn't my main language so I am very sorry if you don't understand me clearly!</p>