1

We are developing a multi tenant application where we are using sing SessionFactory – multiple DataSources approach. We have written a DataSourceProxy and configured this to SessionFactory which switches b/w datasources based on tenantId. As we are using hibernate’s automatic table creation (create) to create tables in schema we need to create tables in each tenant specific schema on switching of dataSource (if not exists). Please let me know if you have any pointers.

Thanks in advance, Prashanth

uma
  • 41
  • 2

1 Answers1

0

If you are using Spring (based on your question, it sounds like you are), you can use the AbstractRoutingDataSource. See my answer on this issue: Multiple Entity Manager issue in Spring when using more than one datasource.

Community
  • 1
  • 1
atrain
  • 9,139
  • 1
  • 36
  • 40