christian wrote:
It's a pattern that is used in almost all Hibernate applications with great success. You do _not_ catch LazyInitializationException. That is the whole point of the pattern. There is ready to use code linked here:
http://hibernate.org/42.html
Don't worry brother, I was just poking fun, that's what my winky emoticon was for :D. My UI jockeys wouldn't know an N+1 selects problem if it bit them in the rear. If I don't completely fill out relevant objects graphs for them my database server would be hella pissed!
I find that OSIV is fine if your backend and UI programmers are one and the same person, but on more complex projects where concerns are highly delineated, you just end up forcing your UI developers to learn complex SQL concepts. My current project is 380 ridiculously overengineered tables (the DBAs had two years to make as much of a mess as possible), and there's no way I'd let the UI guys navigate a lazy-loaded domain graph.