Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate transaction problem
    text
    copied!<p>We are using Hibernate Spring MVC with OpenSessionInView filter. Here is a problem we are running into (pseudo code)</p> <pre><code>transaction 1 load object foo transaction 1 end update foo's properties (not calling session.save or session.update but only foo's setters) validate foo (using hibernate validator) if validation fails ? go back to edit screen transaction 2 (read only) load form backing objects from db transaction 2 end go to view else transaction 3 session.update(foo) transaction 3 end </code></pre> <p>the problem we have is if the validation fails foo is marked "dirty" in the hibernate session (since we use OpenSessionInView we only have one session throughout the http request), when we load the form backing objects (like a list of some entities using an HQL query), hibernate before performing the query checks if there are dirty objects in the session, it sees that foo is and flushes it, when transaction 2 is committed the updates are written to the database. The problem is that even though it is a read only transaction and even though foo wasn't updated in transaction 2 hibernate doesn't have knowledge of which object was updated in which transaction and doesn't flush only objects from that transaction. Any suggestions? did somebody ran into similar problem before</p> <p>Update: this post sheds some more light on the problem: <a href="http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/" rel="nofollow noreferrer">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/</a></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