So far, my work with hibernate has been in standard java programs. I'm now moving my domain model to the web after testing, but I'm getting confused when reading about the proper "patterns" in using sessions in this environment.
So far, it seems that my best option, would be to start a session at the beginning of my servlet, do the work, and end the session. However, my application will be using "application transactions" stated in the page:
http://www.hibernate.org/168.html
For example, a user will load an object into a web page, wait 5 minutes, then click "save" (or 1 minute, or 10 minutes). That would require me to load the detached object back in.
However, what would happen to my session if a user just closes the web page? I would need a way to close this session, rather than it just hang. What if multiple users just close the web page in the middle of this "application transaction"?
Can someone give me some "blueprints" / best-patterns with something like this?
I plan on using the hibernate deployer in JBoss to deploy my application, and just load the sessions from JNDI in my servlets for now. But this will be my first time using JBoss / Hibernate, and am curious on other programmer's experience/advice.
Thanks!!
--Neelixx