You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to declare a Flyway Spring bean that get initialized just before Hibernate starts to validate the underlying database schema in order to apply database migration scripts.
Expected behaviour
Here is what I like to do. I want to register Flyway as a Spring bean and inject the dataSource into it. In order to have Flyway run its db migrations before Hibernate starts to validate the underlying database schema I add the flyway bean as a dependency onto the hibernateDatastore bean. The expected bean creation order should then be as follows:
dataSource
flyway
hibernateDatastore
Actual behaviour
The problem is that the Grails Hibernate plugin defines first a bean called hibernateDatastore. This is triggering Hibernate to validate the underlying database schema. After creating the hibernateDatastore the plugin tells Spring to execute the BeanDefinitionRegistryPostProcessor of org.grails.orm.hibernate.support.HibernateDatastoreConnectionSourcesRegistrar registers a dataSource bean. For my use case this should be the other way around as it was in previous versions of Grails.
The following question at Stackoverflow provides further code listings that were running in Grails <= 3.2.x
The text was updated successfully, but these errors were encountered:
Previous versions of Grails created the dataSource bean separately from the session factory. We would need to restore this behaviour I guess so the dataSource can be referenced without triggering the creation of the sessionFactory
graemerocher
added a commit
to grails/grails-data-mapping
that referenced
this issue
Aug 23, 2017
I am trying to declare a Flyway Spring bean that get initialized just before Hibernate starts to validate the underlying database schema in order to apply database migration scripts.
Expected behaviour
Here is what I like to do. I want to register Flyway as a Spring bean and inject the
dataSource
into it. In order to have Flyway run its db migrations before Hibernate starts to validate the underlying database schema I add theflyway
bean as a dependency onto thehibernateDatastore
bean. The expected bean creation order should then be as follows:Actual behaviour
The problem is that the Grails Hibernate plugin defines first a bean called
hibernateDatastore
. This is triggering Hibernate to validate the underlying database schema. After creating thehibernateDatastore
the plugin tells Spring to execute theBeanDefinitionRegistryPostProcessor
oforg.grails.orm.hibernate.support.HibernateDatastoreConnectionSourcesRegistrar
registers adataSource
bean. For my use case this should be the other way around as it was in previous versions of Grails.The following question at Stackoverflow provides further code listings that were running in Grails <= 3.2.x
The text was updated successfully, but these errors were encountered: