I am trying to develop a code in JPA that can switch between 2 data sources. It would be some thing like this, where useOracleDS is the environemnt variable:
if (useOracleDS){
Call method setPersistenceUnitName("oracle") on object of LocalContainerEntityManagerFactoryBean.
}
else{
Call method setPersistenceUnitName("informix") on object of LocalContainerEntityManagerFactoryBean.
}
Some extra info, the two data sources are for production(informix) and DR(oracle) hence they have the same table names etc.
My question is this option correct or there are other good options in JPA for do the switching between 2 data sources.
I have just started using JPA so any help on this would be greatly appreciated.