Multiple Data Sources with same entity and repo

↘锁芯ラ 提交于 2019-11-28 12:55:16

You need to look at AbstractRoutingDataSource and use it.

So if I need to search for User John Doe I have to go through Schema 1 and if I don't find him, move onto the next schema.

Thus you need to search in first schema and if not found, then go on to next schema.

In that example as given in the above link,

 CustomerContextHolder.setCustomerType(CustomerType.GOLD);
 List<Item> items = catalog.getItems();
 if(isEmpty(goldItems)){
  CustomerContextHolder.setCustomerType(CustomerType.SILVER);
  items = catalog.getItems();  
 }

More details can be found in another qn here

Managed to resolve the issue by using https://github.com/wmeints/spring-multi-tenant-demo.

Thanks @surya for your recommendation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!