How to use injected dataSource in Grails to perform operations?

只谈情不闲聊 提交于 2020-01-04 07:21:37

问题


Is there a way to use an injected datasource in grails for specific operations such as .createCriteria() , .list(), and .find()?

I have tried the following:

def dataSource_test //Injected dataSource

DomainClass.dataSource_test.createCriteria() //returns no property for domain class
DomainClass.createCriteria(dataSource_test) //returns no matching method for argument

I know it is possible to do the following way:

DomainClass.test.createCriteria()

This way however gives me more issues, linked here: Validation using wrong datasource when using multiple datasources in Grails?


回答1:


Is there a way to use an injected datasource in grails for specific operations such as .createCriteria() , .list(), and .find()?

No. We support multiple datasources and provide a mechanism for expressing which datasource you want a particular query to be associate with, but that isn't what you are asking about. We do not provide a way for you to associate GORM methods with a data source that you have injected into an artifact.



来源:https://stackoverflow.com/questions/26564026/how-to-use-injected-datasource-in-grails-to-perform-operations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!