If it is okay to copy the state of the given object onto the persistent object with the same identifier, the following will do the trick:
... attachedEntity = myHibernateSession.merge(detachedEntity); ...
Be aware of the semantics of the merge operation defined by JSR-220.
Otherwise, you could simply do a fetch join when you retrieve the object initially to also retrieve required dependencies.
Thanks for the hint, jacob.orshalick. Actually, the problem is however not about re-associating a single know entity to the new session but rather about re-associating all entities in the current long running transaction. So the challenge is much rather how to find / enumerate all entity objects that exist in the current transaction.
btw: I already knew session.merge() and a few other hibernate tricks that re-associate a single entity, but a "grep" through the Seam source (Seam2.0.0.BETA1) had shown me that Seam does not actually use merge() to achieve the goal even before I started this thread.
What is the easiest way to manually re-associate all detached entities in my conversation with the new session of the current request? I tried to study the Seam source code but did not discover which trick Seam uses to achieve this so smoothly an transparent.
Seam supports the concept of a Seam-managed conversation-scoped persistence context, which is an extended persistence context whose lifetime is tied to the lifetime of a conversation.
If such a Seam-managed persistence context is used, Entities don't get detached between requests but stay managed as long as the conversation (or application transaction) lasts.
See chapter "Chapter 8. Seam and Object/Relational Mapping", section
"8.3. Seam-managed persistence contexts" of the reference manual for more information.