title: Handle multiple EntityManager in Java EE application
body: <p>I have Java EE application with about 10 EntityManagers (number of EMs will probably increase). My application also contains many stateless, statefull and message driven beans.</p>
  
  <p>Rather than inject in each bean my EMs with <code>@PersistenceContext</code> (and 2 methods to detect which EM to use for user), I probably store all of that inside a singleton bean and access it with others beans. Like that, no worries about maintainability.</p>
  
  <p>Nevertheless, is it thread-safe to store EMs inside one singleton bean? Can a bottleneck appear?</p>
  
  <p>Another solution is to create an abstract class and all beans will extend it.</p>
  
  <p>What is the better solution?</p>