I'm currently making use of the Open Session In View pattern.
However, I create 2 transactions, one for the action, one for the view. I'm also making use of the thread local session context.
When I commit a transaction for the action, I need to get a new session object instead of re-using the previous session. getCurrentSession() returns me a new Session object after I commit. I assume this is the normal behavior for the thread local context configuration.
However, if I start a new transaction using this new Session, and use this transaction for the view, and the view involves lazy loading of objects, I eventually get the following JDBC connection error:
Code:
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
.
.
.
Caused by: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
If I switch to flushing after the action (but before the view) instead of committing, i.e. avoiding using 2 transactions, this error does not occur. I assume that lazy loading from an object that belongs to a previous transaction (and session?) is leaving the session connection open.
How can I resolve this situation?