title: Java Hibernate save an object and update a different object using the same session in the same transaction only update and not save
body: <p>What I'm trying to do is when the customer order a product the order will be save to the DB and that product will be updated.</p>
  
  <pre><code>Session session = factory.openSession();
  Transaction t = session.beginTransaction();
  
          try {
              session.update(product);
              session.save(order);
              t.commit();
          }
          catch (Exception e) {
              t.rollback();
          }
          finally {
              session.close();
          }
  </code></pre>
  
  <p>The product and the order are 2 different object type. I got no exception when running this code but only the product got updated, the order was not saved.</p>
  
  <p>Sorry for my bad English.</p>