Hibernate: Understanding Lazy Fetching: I found last night a interesting and well explained Hibernate article on JavaLobby web site authored by R.J.Lorimer and since Hibernate is on my interest list….and I belive yours too..I publish here a link to it. Thank you, R.J.
I had the same problem. Hibernate documentation gives us a description of the two approaches. I chose the clean 2 tier/closed session approach, implemented mainly with Criteria not with Query, because you can state clearly the FetchMode you want for your members/properties. It certainly has some disadvantages like:
– eliminates the caching 😦 – a big performance hit here
– forces you to fetch data even if you don’t need it OR complicates your data logic function (“To Fetch ..Or Not To Fetch? … That Is The Question” – HiberHamlet by HiberTitan + a guy named Shakespeare)