|
That is perfect.
I will try to explain our use case: For very special fields (legacy fields) but widely used we have implemented a hibernate CompositeUserType. This UserType maps the 1 side of some legacy n:1 entities. For the 1 side entities we implemented a proxy for custom lazy loading (legacy). So just like hibernate lazy loading an entity we can lazy load our legacy entity. This proxy on loading entities requires access to a thread local Accessor instance which is usually created and set by a servlet filter on every http request thread. The Accessor takes care of performance optimizations on loading legacy entities during the whole http request until the request/thread is finished (legacy caching). And therefore the same instance of the thread local should be bound to the thread and used throughout the whole request. In case of multiple threads we usually create new instances of this Accessor for each request and bind it as a thread local (like we do in asynchronuous jobs).
Thomas
|