bdusauso wrote:
You surely misuse Hibernate but it depends on what you want to accomplish. Maybe the
"Open Session In View" pattern is what you want to use.
Yes, I realize that I'm not using the best hibernate pattern, but it is one that is discussed quite a bit in the docs.
bdusauso wrote:
But for your specific question, lazily loading an object implies it's bound to a session, otherwise you'll have an exception (it's a normal behaviour : if the object is not bound to a session, it means that it's not under hibernate's control, thus you cannot fetch anything more than what has been fetched before).
I'm not seeing any information regarding the thread safety of a session in your reply. Maybe I'm dense.
I'm aware that I need to have an object bound to a session before anything can happen. I'm using session-per-conversation, where the session isn't closed between requests... the transaction is just committed and a new one is started for the next request.
From the hibernate manual, section 11.1.4:
Quote:
• A Session is not thread-safe. Things which are supposed to work concurrently, like HTTP requests, session beans, or Swing workers, will cause race conditions if a Session instance would be shared. If you keep
your Hibernate Session in your HttpSession (discussed later), you should consider synchronizing access to your Http session. Otherwise, a user that clicks reload fast enough may use the same Session in two concurrently running threads.
As in my original post, I'm wondering if the hibernate session object gets involved even when not explictly referenced, ie. by modifying an object, or accessing an object's property that causes some lazy loading to occur.
The paragraph from the manual just suggests taking a shotgun to the problem. I'm wondering if I can be a little more fine grained about it.
-Trevor