
Originally Posted by
rhasselbaum
In our app, we use a callback mechanism to allow the web tier to do lazy-loading of an object graph when it needs to. The method that performs the callback runs within a transaction/session. Although the web tier doesn't need to know that.
This is fine within the View, if you're loading a fresh object first.
But in the controller, if you're using Hibernate anyway, you can easily run into an error saying something like "attempt to reconnect an object with dirty collections" (I don't remember the exact wording).
This is because before loading the collection, you have to reconnect the object to the current session using:
Code:
this.getHibernateTemplate().lock(entity, LockMode.NONE);
If you lazy-load one collection first, modify the collection in any way, and then lazy-load another collection, you'll get the error.