-
Notifications
You must be signed in to change notification settings - Fork 40.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataSourceInitializedEvent picks wrong datasource #17061
Comments
Turns out we're relying on something that isn't defined in the spec
I think the Hibernate team are going to change their code, but we should also look if there's something we can do locally. |
We're unfortunately very light on tests for |
With spring boot 2.1.x the
DataSourceInitializedEvent
picks the wrong datasource again because the property to get the datasource from theEntityManagerFactory
changed tohibernate.connection.datasource
compared tojavax.persistence.nonJtaDataSource
used in the fix for #8296.As a workaround one can fix this by passing the legacy property
javax.persistence.nonJtaDataSource
to theEntityManagerFactoryBuilder
with the correct datasource. I have created a minimal example with everything needed to initialize two datasources at https://github.com/m-kay/spring-boot-init-two-datasources and you can see the fix inFirstDbConfig
line 84 andSecondDbConfig
line 83. I had to create my ownDataSourceInitializer
which executes init scripts after the event is fired for my second datasource, since the defaults only work with a single datasource.The text was updated successfully, but these errors were encountered: