Okay I have gotten to the bottom of my problem, in the filter I have code like:
Code:
if (session != null && session.isOpen()) {
if(transaction != null) {
transaction.rollback();
transaction = null;
}
session.close();
session = null;
}
sessionContext.set(null);
It seems that when I call Session.commit() this sets the private boolean Session.closed=true but does not actually do a real session close.
What does isOpen() mean, documentation suggests my usage is correct, it relates to the state of the session not transaction.
So my filter does not call session.close() and the DB handle is not returned to the pool.
As a second question is it valid to issue read only data operations, and lazy loading after I call commit(). The commit() is called at the end of the controller part of MVC, this is before the view is rendered. I'm using open session in view. I could defer the commit until the filter, but then I couldn't indicate a commit() error to the user for his operation.
So it it valid to do:
open();
get();
saveOrUpdate()
commit();
get();
# Lazy loading here... no write operations
close();