SpringSource/grails-data-mapping — pull request #122 by michaelcameron (2013-05-21 19:43:56+00:00)
Title: GRAILS-9773 - Fix HibernatePersistenceContextInterceptor usages with multiple datasources

`HibernatePersistenceContextInterceptor` uses a static `ThreadLocal` to manage nesting, but `AggregatePersistenceContextInterceptor` creates one `HibernatePersistenceContextInterceptor` per datasource so the wrong behavior occurs on `init()` and especially `destroy()`. Since `HibernatePersistenceContextInterceptor` is essentially a singleton per datasource it's safe (and proper in this case) to use a local ThreadLocal on `HibernatePersistenceContextInterceptor`.