I tend to use Hibernate in combination with Spring framework and it\'s declarative transaction demarcation capabilities (e.g., @Transactional).
As we all known, hib
I am not sure which problem (caused by lazyness) you're hinting to, but for me the biggest pain is to avoid losing session context in my own application caches. Typical case:
foo is loaded and put into a map;foo.getBar() (something that was never called before and is lazy evaluated);So, to address this we have a number of rules:
OpenSessionInViewFilter for webapps);try/finally) so subclasses don't have to think about it;This, as you can see, is indeed nowhere close to non-invasive and transparent. But the cost is still bearable, to compare with the price I'd have to pay for eager loading. The problem with latter is that sometimes it leads to the butterfly effect when loading single referenced object, let alone a collection of entities. Memory consumption, CPU usage and latency to mention the least are also far worse, so I guess I can live with it.