title: Multiple Session Factories under Spring/Hibernate
body: <p>I have been given a requirement where I need to support multiple databases in the same instance, to support multi-tenancy. Each DB has an identical schema. The user logs into a specific database by choosing from a list, and all subsequent calls will go to that DB until they log out.</p>
  
  <p>I want to hot swap the session factory inside a single HibernateDaoTemplate based on a parameter supplied by the client. </p>
  
  <p>I can find lots of stuff on hot-swapping data sources (and all the transaction issues associated with that) but I want to hot swap session factories - retaining all the caching for each.</p>
  
  <p>What's the easiest way to do this? Configure a HotSwappableTarget for the DaoTemplate? Can anyone point me to samples on how to do this?</p>