title: Using Spring, JPA with Hibernate to access multiple databases/datasources configured in Jboss
body: <p>I have a requirement where i need to configure a Spring based application to work with two databases. We have two databases, one that we use to keep the live data and the other database is used as a datawarehouse and contains archived data (which has the exact structure as the Live db). </p>
  
  <p>To keep it simple, assume that there is a request to search for a product. What the application should do is to search for the product details in the Live database and if not found it will check the archive database. </p>
  
  <p>If i need to configure such a setup, do i still need to configure to datasources and would the search code have to use the first datasource to check the live database and if not found it will run another query using the archive database? </p>
  
  <p>The above is probably doable but i am wondering whether there is a better way of doing this. For example, is it possible for the application to work on a single datasource even though behind the scenes it actually works with two databases? </p>
  
  <p>The application is based on Spring, JPA/Hibernate, SOAP and Mysql database and Jboss 7 as the application server.  </p>
  
  <p>Any examples showing how this is configured using Spring and Jboss would be very useful. </p>
  
  <p>Thanks</p>