1

I've implemented the AbstractRoutingDataSource in order to horizontally partition my data [1]. I rely on Hibernates functionality to create and update the database schema. This works fine for the first datasource, which is resolved by the determineCurrentLookupKey() declared in AbstractRoutingDataSource.

Is there a way to apply the schema generation/update to the other datasources as well?

I've found the classes SchemaExport and SchemaUpdate respectively, that are capable of the required functionality. However, both require an instance of org.hibernate.boot.MetaData, which I don't how to obtain.

(I'm using Spring Boot in version 1.4.2.RELEASE.)

[1] https://spring.io/blog/2007/01/23/dynamic-datasource-routing/

Thanks!

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
twiechert
  • 83
  • 1
  • 7

1 Answers1

0

I got the same issue and found a solution using the SchemaExport class of hibernate. For each DataSourceEnum you can manually initialize the datasource.

here is my detailed answer to my own issue discription

climax85
  • 79
  • 1
  • 6