title: Hibernate is throwing managed flush exception
body: <p>We are trying to save entity in Oracle : <strong>Oracle Database 11g</strong> Enterprise Edition Release 11.2.0.3.0</p>
  
  <p>We are using <strong>Hibernate</strong> for same:</p>
  
  <p>We are getting following distinct error:</p>
  
  <pre><code>o.h.i.ExceptionMapperStandardImpl : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
  </code></pre>
  
  <p>Detailed relevant stacktrace is as below:</p>
  
  <pre><code>[ERROR]--- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : ORA-00001: unique constraint (XXX.PK_USER_FAVORITE) violated
   [WARN ]  --- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1, SQLState: 23000
  [ERROR] --- [nio-8080-exec-9] o.h.i.ExceptionMapperStandardImpl : HHH000346: Error during managed flush [**org.hibernate.exception.ConstraintViolationException**: could not execute statement]
  [ERROR] --- [nio-8080-exec-9] c.mastercard.refarch.aop.ServiceLogging : {"aop_service":"UserFavoritesService", "method":"addCurrentUserFavorite", "type":"failed", "error":"could not execute statement; SQL [n/a]; constraint [XXX.PK_USER_FAVORITE]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement", "args":"(["s029158",{"userFavoriteId":null,"applicationId":"XXX","functionAlphaCode":"SOME vale","title":"Service Report"}])"}
  </code></pre>
  
  <p>We are using <strong>oracle sequence</strong> for generating primary key value. I guess we are getting above issue when oracle sequence is trying to execute. <strong>Hibernate is failing to execute Oracle sequence whenever we get above exception</strong>, Thats main smell here. </p>
  
  <p>There is also <strong>not null</strong> and <strong>primary key constraint</strong> on Entity that we are trying to save on DB.</p>
  
  <p>Current Hibernate Version is <strong>Hibernate-core 5.2.17</strong>
  and version if hibernate JPA is <strong>Hibernate-JPA-2.1-API-1.0.2.Final</strong></p>
  
  <p>Still wondering why we are getting :</p>
  
  <p><strong>Error during managed flush [org.hibernate.exception.ConstraintViolationException:</strong></p>