-
-
Notifications
You must be signed in to change notification settings - Fork 75
SessionFactory bean has another name as expected #973
Comments
+1 the same issue in both versions 3.0.4 and 3.1.0 is looking for session factory by concatinating "sessionFactory" and datasource bean name, not a datasource name: String dataSourceName = getDataSourceName(dataSource)
String sessionFactoryName = "sessionFactory"
if (!isDefaultDataSource(dataSource)) {
sessionFactoryName = sessionFactoryName + '_' + dataSourceName
} so if your data source is "audit", then "getDataSourceName()" will return "dataSource_audit" as needed to get another bean, but session factory bean name will be "sessionFactory_audit", so it will fail to find "sessionFactory_dataSource_audit" Also using Grails: 3.3.9 and database-migration:3.0.4 |
just hit this one as well. pull-request targeting there it is: grails/grails-database-migration#164 |
when constructing the sessionFactory bean name for a secondary dataSource, just append the suffix, not the complete dataSource bean name (i.e. sessionFactory_another instead of sessionFactory_dataSource_another)
See grails/grails-database-migration#164 - this may still be an issue. |
thanks for the ping! just signed the cla for that pr - feel free to port to this repo (just saw the move). |
@zyro23 would you have time to confirm this is still an issue in Grails 6 or Grails 7? |
yup, will take a look ( |
…7 (grails-database-migration-9.0.0-SNAPSHOT)
When multiple data sources are used, then dbm-gorm-diff, dbm-generate-changelog, etc. fail for the non default data sources:
For example:
We have default data source and 'another' data source in our application.yml
Running:
dbm-gorm-diff --dataSource=another
Fails with:
No bean named 'sessionFactory_dataSource_another' available
Cause:
No bean named sessionFactory_dataSource_another is registered. But list of registered beans contains sessionFactory_another.
Workaround:
We added
into grails-app/conf/spring/resources.groovy
The text was updated successfully, but these errors were encountered: