I'm working with JSF and this is starting to seem like a dead-end. I want to store objects from the a Hibernate-mapped class in session-scoped managed-bean class. The first step was to call this:
Code:
sessionFactory.getCurrentSession().buildLockRequest(LockOptions.NONE).lock(obj);
To avoid a LazyInitializationException and re-attach the object to the session whenever I needed to do something with it.
After that I've been getting "reassociated object has dirty collection" whenever I change a collection for an object and then try to access that object again. The only way around that was calling merge for the object. However that also resets all none-persistent properties of that object. I've Googled a lot for this but I can only seem to find confirmation that this is indeed the way it's suppose to be... Calling update, save, saveOrUpdate etc. that for object also still results in the same error.