Suppose a field has a validator, and the field is made invalid (age < 0).  When flushing, the validator runs, and throws an exception.  The exception handling section (http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#transactions-demarcation-exceptions) states that if any method throws an exception, the session must be closed.

 

So, what to do if session-per-conversation is used?  If hibernate validation is used, then flush of invalid data corrupts the session – the application then needs to ask the user to start over, or else build complex recovery logic (new session, copy data to new session).

 

How does hibernate validation interact with extended sessions?

 

-Justin

office 8-383-6725, 212-272-6725; cell 917-861-6042