title: Hibernate 5: Inserting Data
body: <p>Currently, I am having this code to insert a <code>Product</code> object and it works totally fine!</p>
  
  <pre><code>public void insertProduct(Product product) {
      Session session = this.databaseDriver.openSession();
  
      Transaction transaction = session.beginTransaction();
      session.save(product);
      transaction.commit();
  
      session.close();
  }
  </code></pre>
  
  <p>However, this code does not seem to work:</p>
  
  <pre><code>public void insertProduct(Product product) {
      Session session = this.databaseDriver.openSession();
  
      session.save(product);
      session.flush();
      session.close();
  }
  </code></pre>
  
  <p>What would be the reason for this? Neither does it give me any errors nor insert the data.</p>