title: Multi-Tenant and Central Database with Spring Boot and Hibernate
body: <h1>Specification</h1>
  
  <p>Each tenant has their own database which handles users in greater detail, and there needs to exist a central database which handles:  </p>
  
  <ul>
  <li>Tokens (OAuth2)</li>
  <li>Users (limited level of detail)</li>
  <li>Mapping users to their database</li>
  </ul>
  
  <h1>Problem</h1>
  
  <p>I've found <a href="https://stackoverflow.com/questions/50472097/variable-datasource-based-on-user">solutions</a> for multi-tenancy which allows me to determine the datasource depending on the user. However, I'm not sure how I can also link certain crud repositories to this central datasource, and others to variable datasources. </p>
  
  <p>Another <a href="http://jeroenbellen.com/manage-and-reload-spring-application-properties-on-the-fly/" rel="nofollow noreferrer">solution</a> involved updating the properties file, and using a configuration server (i.e. via git) to trigger @RefreshScope annotated configs. Though I'm not sure if this can work for Datasources, or if this could cause problems later on.</p>
  
  <h2>Extra Context</h2>
  
  <p>I'm using Spring Boot and Hibernate heavily in this project.</p>