Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had this problem too! I'm using Spring annotation transaction (@Transactional) and I'm getting some method actually doing the session.flush(), and other not!</p> <p>From my debug log I have:</p> <p><code>transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!</code></p> <p>The session.close() has to be called from Spring TransationManager, but I'm not sure what's going on: I double-checked my Spring configuration and I cannot argue why this is happening. I further investigate and I'll repost any hint but if someone has some useful advice I'ld be very grateful :o)</p> <p>Update: The problem seems related to hibernate session flush mode = MANUAL: it didn't flush objects at the end of Spring's transaction.</p> <p>You can verify your current flush mode with something like:</p> <pre><code>SessionFactoryUtils.getSession(mySessionFactory(), false).getCurrentSession().getFlushMode() </code></pre> <p><br></p> <h2>UPDATE [SOLVED FOR ME]:</h2> <p>I dug a lot into my problem and found the origin of the problem and a workaround.</p> <p>I had, as you if I understand well, an intermittent problem where some transactions were closed correctly (i.e. hibernate sessions were flushed) and some others not.</p> <p>I discovered that:</p> <ol> <li><p>the problem was due to <code>flushMode</code> set to <code>FlushMode.MANUAL</code> when I entered the transaction (that not trigger the flush operation when transaction commits);</p></li> <li><p>this in turn was due to something nasty going on between Spring and ZK (the bad transactions were all from ZK's composers - if you don't know ZK, they are called from servlets, roughly equivalent to Struts' actions);</p></li> <li><p>the precise problem lies in the Spring's <code>OpenSessionInViewFilter</code> not correctly communicating with ZK's filters: the Hibernate session provided by <code>OpenSessionInViewFilter</code> is not getting its flush mode correctly set. The single ZK composer works well (I've tested it from some JUnit tests), as well as the <code>OpenSessionInViewFilter</code> alone (I've tested it from a plain Servlet using <code>WebApplicationContextUtils</code>).</p></li> </ol> <p>Conclusion: I call <code>session.flush()</code> at the end of every @Transactional method in my composers, and I'll migrate to Vaadin (much much simpler to integrate, it seems).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload