Im not trying to argue, I just didnt understand the line in the document
Quote:
"Don't use the same Session for multiple application transactions"
I guess for now I will assume that this means multiple transactions at the same time, and not serial (see my code post above)
anthony wrote:
- what happens if a user go away take a coffe? his httpSession keeps living, it stores hibernate session which is linked to a jdbc connection and so:
I was going to have a J2EE session listener which would close the Hibernate session. Also, at the end of each J2EE request, have a request listener which gives the JDBC connection back from the Hibernate session so the JDBC connections arent idle and unused
anthony wrote:
You can exactly have the same behaviour using threadlocal pattern, extremely usefull and more secure
I dont know how using the ThreadLocal object would help me here. Since I want a session attached to a J2EE session, not the thread (which could be servicing multiple people).
OK, so unless someone tells me otherwise, I will go forward with 1 Hibernate session linked to the user's J2EE session, and never restarting the Hibernate session midway through the J2EE session. Thanks, Chris