title: Why would HibernateTemplate.merge() complete without exception but not persist data?
body: <p>I would like to make this question as generic as possible without submitting extensive code and configuration samples so that answer submitters can cover a wide range of possibilities, therefore make it somewhat "academic".</p>
  
  <p>I have two entity classes, <code>Foo</code> and <code>Bar</code>. They are wired to the persistence store (in my case <code>PostgreSQL</code> but I think that shouldn't matter) using <code>JPA</code> with <code>Hibernate</code> as the provider. They are managed by <code>FooDao</code> and <code>BarDao</code> respectively and both DAOs extend a <code>BaseDao</code> which contains a save method:</p>
  
  <pre><code>public T save(T object)
  {
  
      return (T) hibernateTemplate.merge(object);
  }
  </code></pre>
  
  <p>which neither DAO overrides (meaning they use the superclass method as is).</p>
  
  <p>The problem is, when I call <code>myFooDao.save(myFoo)</code>, it actually persists the objects to the DB but when I call <code>myBarDao.save(myBar)</code>, the object is not persisted, <strong>YET NO EXCEPTION IS THROWN</strong>.</p>
  
  <p>All of this runs out of a <code>Spring</code> context and both DAOs are <a href="https://en.wikipedia.org/wiki/Dependency_injection" rel="nofollow">injected</a>. I should also add both tables have primary keys each tied to its own sequence. While the Bar insertion never actually gets persisted, the associated sequence does get incremented every time, which is odd. So Hibernate does prepare a transaction but getting the next value from the sequence, which increments the sequence, but the new row never shows in the datable.</p>
  
  <p>I am looking to explore some general circumstances under which anomaly can occur. For one, could it be that the configuration is set so that Foo is auto-committed but Bar is not and I should dive into the context configs to find discrepancies? Or could it be that Hibernate thinks the write is successfully committed because the DB engine does not report a failure properly? </p>