title: Why hibernate do Executing identity-insert immediately
body: <p>When I run test I see in logs <code>Executing identity-insert immediately</code> Why hibernate run immediately insert? I expect insert during commit.</p>
  
  <pre><code>On TransactionImpl creation, JpaCompliance#isJpaTransactionComplianceEnabled == false
  begin
  Executing identity-insert immediately
  
      /* insert MyJpaClass
          */ insert 
          into
              MyJpaClass
              (id, message) 
          values
              (null, ?)
  Hibernate: 
      /* insert MyJpaClass
          */ insert 
          into
              MyJpaClass
              (id, message) 
          values
              (null, ?)
  Natively generated identity: 1
  HHH000387: ResultSet's statement was not registered
  committing
  Processing flush-time cascades
  Dirty checking collections
  Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
  Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
  Listing entities:
  MyJpaClass{id=1, message=text}
  Initiating JDBC connection release from afterTransaction
  Initiating JDBC connection release from afterTransaction
  </code></pre>
  
  <p>This is my test example
  Persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
                                   http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0"&gt;
  &lt;persistence-unit name="HelloWorldPU" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
  
      &lt;properties&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/&gt;
          &lt;property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/&gt;
          &lt;property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"/&gt;
          &lt;property name="javax.persistence.jdbc.user" value="sa"/&gt;
          &lt;property name="javax.persistence.jdbc.password" value=""/&gt;
  
          &lt;property name="hibernate.show_sql" value="true"/&gt;
          &lt;property name="hibernate.format_sql" value="true"/&gt;
          &lt;property name="hibernate.use_sql_comments" value="true"/&gt;
          &lt;property name="hibernate.transaction.factory_class"
            value="org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory"/&gt;
          &lt;property name="hibernate.id.new_generator_mappings" value="true"/&gt;
          &lt;property name="hibernate.connection.autocommit" value="false"/&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="create-drop"/&gt;
  
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>Test</p>
  
  <pre><code>import static org.junit.Assert.assertNotNull;
  
  import java.io.FileNotFoundException;
  import java.sql.SQLException;
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.Persistence;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
  import org.junit.AfterClass;
  import org.junit.BeforeClass;
  import org.junit.Test;
  
  public class PersistTest {
      Logger LOG = LogManager.getLogger(PersistTest.class);
  
      protected static EntityManagerFactory emf;
      protected static EntityManager em;
  
      @BeforeClass
      public static void init() throws FileNotFoundException, SQLException {
          emf = Persistence.createEntityManagerFactory("HelloWorldPU");
          em = emf.createEntityManager();
      }
  
      @AfterClass
      public static void tearDown(){
          em.clear();
          em.close();
          emf.close();
      }
  
      @Test
      public void testPersist_success() {
          em.getTransaction().begin();
          MyJpaClass o = new MyJpaClass();
          o.setMessage("text");
          em.persist(o);
          em.getTransaction().commit();
  
          assertNotNull(o.getId());
          LOG.debug(o.getId());
      }
  }
  </code></pre>
  
  <p>Entity</p>
  
  <pre><code>import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
  @Entity
  public class MyJpaClass {
  
      @Id
      @GeneratedValue (strategy= GenerationType.IDENTITY)
      private Long id;
  
      private String message;
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getMessage() {
          return message;
      }
  
      public void setMessage(String message) {
          this.message = message;
      }
  }
  </code></pre>