Reputation: 51
I have multiple data sources in my application and I want to be able to switch the datasource on a service class from the default one to a different one (so that it matches my Grails domain). Per the doc it states to use:
static datasource = 'dsName'
property on the service class, which I have done. However, the mainTransactionManager is still using my default data source.
I can see in the ChainedTransactionManager that it calls:
MultiTransactionStatus mts = new MultiTransactionStatus(transactionManagers.get(0));
The 0th index inside of transactionManagers contains my default data source... so how do I ensure that it doesn't use the transaction manager that contains the default data source?
Where/when does Grails read the
static datasource = '...'
property?
Basically I just want to lineup my datasource across my services and my domains.
Upvotes: 0
Views: 225
Reputation: 27220
Where/when does Grails read the
static datasource = '...'
That property is read at https://github.com/grails/grails-core/blob/bd7cc10e17d34f20cedce979724f0e3bacd4cdb4/grails-plugin-services/src/main/groovy/org/codehaus/groovy/grails/plugins/services/ServicesGrailsPlugin.groovy#L74
That is invoking the getDatasource
method at https://github.com/grails/grails-core/blob/bd7cc10e17d34f20cedce979724f0e3bacd4cdb4/grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsServiceClass.java#L40.
Upvotes: 1