This wiki has a great section on Why can't Hibernate just load objects
on demand? but it would be nice if someone could throw a concrete very
common example on why it is important to make sure you have repeatable
reads.
My crappy example was you might be navigating from 2 different objects
to the same object and end up with two versions of that same object. ie.
child.getParent() which returns User object
shirt.getBuyers() which returns a list of User objects.
The list would have the same User object as the getParent method
returned but all of the data could have been changed. Then you might
display that in a GUI. Of course, the challenge back was that this
happens like .05% of the time so why complicate things by always having
to fix the LazyInitializationException...people spend more time with
that and fixing that so it is not worth it. It seemed like a decent
argument to me. Anyone with better examples, PLEASE post them!!!! |